In this python numpy program, we will convert 2 arrays as columns of the matrix using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create two 1-dimensional arrays using np.array().
- Now convert those two 1-dimensional arrays as columns of the matrix using np.column_stack().
- 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]]