How to get shape of NumPy array?
The shape method determines the shape of NumPy array in form of (m, n) i.e (no. of rows) x (no. of columns).
import numpy as np array1d = np.array([1, 2, 3, 4, 5, 6]) array2d = np.array([[1, 2, 3], [4, 5, 6]]) array3d = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]) print(array1d.shape) print(array2d.shape) print(array3d.shape)
Sample output of above program.
(6,)
(2, 3)
(2, 2, 3)
2019-02-02T11:37:52+05:30
2019-02-02T11:37:52+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution