Inspecting Your Array
import numpy as np# sample array
data = np.full((3, 4), 4)
dataarray([[4, 4, 4, 4],
[4, 4, 4, 4],
[4, 4, 4, 4]])
Array dimensions
data.shape #3x4(3, 4)
Length of array
len(data) # 3 row3
Number of array dimensions
data.ndim # 2D array2
Number of array elements
data.size # 3x4 = 1212
Data type of array elements
data.dtype # return objectdtype('int64')
Name of data type
data.dtype.name # return string'int64'
Convert an array to different type
data = data.astype(float)
dataarray([[4., 4., 4., 4.],
[4., 4., 4., 4.],
[4., 4., 4., 4.]])
data.dtypedtype('float64')