sum():所有的数求和
sum(axis=0):列相加
sum(axis=1):行相加
import numpy as np
a=np.array([[1,1,2],[2,2,3],[4,4,3]])
print(a.sum())
print(a.sum(0))
print(a.sum(1))
运行结果:
22
[7 7 8]
[ 4 7 11]
sum():所有的数求和
sum(axis=0):列相加
sum(axis=1):行相加
import numpy as np
a=np.array([[1,1,2],[2,2,3],[4,4,3]])
print(a.sum())
print(a.sum(0))
print(a.sum(1))
运行结果:
22
[7 7 8]
[ 4 7 11]