Use the resize and reshape method on Numpy array. Data science using Python in Anaconda - Jupyter

import numpy as np

ar1 = np.array([1,2,3,4,5,6,7,8])
ar2 = np.array([1,2,3,4,5,6,7,8])

#It change orignal array
ar2.resize(2,4

#It dose not change orignal array
ar1.reshape(2,4)
print("ar1 :-\n", ar1)
print("ar2: -\n", ar2)


Output: -
ar1 :- [1 2 3 4 5 6 7 8] ar2: - [[1 2 3 4] [5 6 7 8]]