Inspecting Your Array

import numpy as np
# sample array
data = np.full((3, 4), 4)
data
array([[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 row
3

Number of array dimensions

data.ndim # 2D array
2

Number of array elements

data.size # 3x4 = 12
12

Data type of array elements

data.dtype # return object
dtype('int64')

Name of data type

data.dtype.name # return string
'int64'

Convert an array to different type

data = data.astype(float)
data
array([[4., 4., 4., 4.],
       [4., 4., 4., 4.],
       [4., 4., 4., 4.]])
data.dtype
dtype('float64')