内容目录
Axis理解¶
In [3]:
import numpy as np
# 求数组在纵轴下和
x = np.array([[0,1],[2,3]])
print(x)
x.sum(axis=0)
[[0 1] [2 3]]
Out[3]:
array([2, 4])
In [4]:
# 求数组在横轴下和
x.sum(axis=1)
Out[4]:
array([1, 5])
In [5]:
# 求数组在横轴上的最大值
x.max(axis=1)
Out[5]:
array([1, 3])