demo.py(numpy中的常用统计函数):
# coding=utf-8
import numpy as np
t1 = np.arange(12).reshape((3,4))
print(t1)
'''
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
'''
# sum()求和
a = t1.sum(axis=0) # 可以指定哪个轴上相加求和,默认所有元素求和
# a = np.sum(t1, axis=0) # np和t1都有sum()函数
print(a) # [12 15 18 21]
# mean()求平均值
b = t1.mean(axis=0) # 不指定坐标轴,默认所有元素求平均值
print(b) # [4. 5. 6. 7.]