Aug 28, 2024
arr = np.array([[1, 2, 3], [4, 5, 6]])
.flatten()
to convert 2D to 1D:
arr1 = arr.flatten()
.reshape()
to convert 1D to 2D or 3D.arr2 = arr1.reshape(3, 4) # 3 rows, 4 columns
arr3 = arr.reshape(2, 2, 3)
np.matrix()
to convert a 2D array to a matrix for advanced operations.
m = np.matrix(arr)
.diagonal()
..min()
and .max()
.