[Python] Array Attributes of Numpy lib
Attributes of numpy.ndarray:
- numpy.ndarray.shape: Dimensions (height, width, ...)
- numpy.ndarray.ndim: No. of dimensions
= len(shape)
- numpy.ndarray.size: Total number of elements
- numpy.ndarray.dtype: Datatype
import numpy as np def array(): a = np.random.random((5,4)) print(a.shape[0]) #number of rows, 5 print(a.shape[1]) #number of columns, 4 print(len(a.shape)) #2 print(a.size) # 5*4=20 print(a.dtype) #float64 if __name__ == "__main__": #gen_random() array()