import numpy as np
a = np.array([[1,5,3],[4,2,6]])
print(a.min()) #无参,所有中的最小值
print(a.min(0)) # axis=0; 每列的最小值
print(a.min(1)) # axis=1;每行的最小值
结果:
1
[1 2 3]
[1 2]
我们可以快速读取a的形状
假如我们只想读取a的第一维度长度,使用shape[0]
a=np.array([[1,2,3],[4,5,6],[7,8,9]])
a.shape
Out[5]: (3, 3)
a.shape[0]
Out[7]: 3