Convert 2 arrays as columns of the matrix using NumPy

In this python numpy program, we will convert 2 arrays as columns of the matrix using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create two 1-dimensional arrays using np.array().
  3. Now convert those two 1-dimensional arrays as columns of the matrix using np.column_stack().
  4. Print the output.
				
					import numpy as np
x = np.array((3,8,5))
y = np.array((4,0,7))
z = np.column_stack((x,y))
print(z)
				
			

Output :

				
					[[3 4]
 [8 0]
 [5 7]]
				
			

remove single-dimensional entries from a specified shape.

split an array of 10 elements into 3 arrays, each of which has 2, 3, and 5 elements.

Leave a Comment