目录
一、ndim属性
输出array的维度
示例:
import numpy as np
array = np.array([[1, 2, 3], [2, 3, 4]])
print(array) #print the np.array
print(array.ndim) #print the dimension of the np.array
>>>
[[1 2 3]
[2 3 4]]
2
二、shape属性
输出array的形状
示例:
import numpy as np
array = np.array([[1, 2, 3], [2, 3, 4]])
print(array) # print the np.array
print(array.shape) # print the shape of the np.array
>>>
[[1 2 3]
[2 3 4]]
(2, 3)
三、size属性
输出array中数据的个数
示例:
import numpy as np
array = np.array([[1, 2, 3], [2, 3, 4]])
print(array) # print the np.array
print(array.size) # print the size of the np.array
>>>
[[1 2 3]
[2 3 4]]
6
四、dtype属性
输出array的数据类型
示例:
import numpy as np
array = np.array([[1, 2, 3], [2, 3, 4]])
print(array) # print the np.array
print(array.dtype) # print the data type of the np.array
>>>
[[1 2 3]
[2 3 4]]
int32