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

concatenate() से Arrays जोड़ना

concatenate() आपके चुने axis के साथ arrays को end to end जोड़ता है।

In this page:

  1. concatenate()
Syntax
python
np.concatenate((arr1, arr2), axis=0)

concatenate()

np.concatenate arrays का एक tuple लेता है और इन्हें एक existing axis के साथ जोड़ता है। Arrays को हर दूसरी dimension में match होना चाहिए। axis=0 rows stack करता है, axis=1 columns add करता है।

Note: axis=None जोड़ने से पहले सब कुछ flatten करता है।

उदाहरण: concatenate()

python
import numpy as np

a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
print(np.concatenate((a, b), axis=0))
print(np.concatenate((a, a), axis=1))

# Output:
# [[1 2]
#  [3 4]
#  [5 6]]
# [[1 2 1 2]
#  [3 4 3 4]]
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. एक tuple की बजाय arrays को separate arguments की तरह pass करना
  2. mismatched shapes वाले arrays जोड़ना
  3. axis 0 और axis 1 confuse करना
चैप्टर सारांश
  • arrays का एक tuple pass करें
  • दूसरी dimensions match होनी चाहिए
  • axis join direction चुनता है
  • एक नया array return करता है
🔒

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.