← Back to NumPy Course | Chapter 5: Array Manipulation | Lesson 5 of 7

vstack/hstack से Arrays जोड़ना

vstack arrays को एक-दूसरे के ऊपर stack करता है और hstack इन्हें side by side रखता है।

In this page:

  1. vstack/hstack
Syntax
python
np.vstack((arr1, arr2))
np.hstack((arr1, arr2))

vstack/hstack

vstack vertically जोड़ता है (ज़्यादा rows) और hstack horizontally जोड़ता है (ज़्यादा columns)। ये concatenate से convenient shorthands हैं जो 1-D inputs भी sensibly handle करते हैं। np.column_stack 1-D arrays को columns में बदलता है।

Note: दो 1-D arrays का vstack एक 2-row matrix देता है।

उदाहरण: vstack/hstack

python
import numpy as np

a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(np.vstack((a, b)))
print(np.hstack((a, b)))

# Output:
# [[1 2 3]
#  [4 5 6]]
# [1 2 3 4 5 6]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. जब आपका मतलब vstack से था hstack इस्तेमाल करना
  2. mismatched lengths pass करना
  3. एक tuple या list pass करना भूल जाना
चैप्टर सारांश
  • vstack rows add करता है
  • hstack columns add करता है
  • दोनों arrays का एक tuple लेते हैं
  • 1-D inputs के लिए handy
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.