基本屬性
測試代碼
import numpy as np
arr = np.random.rand(3,2,4)
print(arr)
ndim
數組的軸(秩、維數)
print(arr.ndim)
shape
數組的維度(行數和列數)
print(arr.shape)
size
數組所含元素總數
print(arr.size)
dtype
數組中元素類型
print(arr.dtype)
itemsize
數組中每個元素字節大小
print(arr.itemsize)
real
ndarray 對象的內存信息
print(arr.flags)
real和imag
real元素實部
imag元素虛部
print(arr.real)
print(arr.imag)