Important Notice:

Course Content
NumPy Basic in Python (Chapter-13) M3-R5
About Lesson

Joining & Spliting:-

                   Joining (concatenation) of arrays means combining multiple arrays into one and splitting of arrays means splitting one array into many.

 

#Concatenation Example

import numpy as np

a=np.array([10,20,30])

b=np.array([40,50,60])

c=np.concatenate([a,b])

print(a)

print(b)

print(c)

 

#Concatenation Example Using Stack

import numpy as np

a=np.array([[10,20,30],[15,25,35]])

b=np.array([[40,50,60],[45,55,65]])

print(“Original Array is “)

print(a)

print(b)

print(“Arrays Vertically Concatenationn”,np.vstack((a,b)))

print(“Arrays Horizontally concatenationn”,np.hstack((a,b)))

Output:-

Original Array is

[[10 20 30]

 [15 25 35]]

[[40 50 60]

 [45 55 65]]

Arrays Vertically Concatenation

 [[10 20 30]

 [15 25 35]

 [40 50 60]

 [45 55 65]]

Arrays Horizontally concatenation

 [[10 20 30 40 50 60]

 [15 25 35 45 55 65]]

 

 

error: Content is protected !!