Syntax:
np.reshape(a, newshape, order='C')
Example:
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
reshaped = np.reshape(arr, (2, 3))
print(reshaped)
[[1 2 3]
[4 5 6]]
Explanation:
arr is a 1D array: [1, 2, 3, 4, 5, 6]
np.reshape(arr, (2, 3)) reshapes it into a 2D array with 2 rows and 3 columns.