import numpy as np
x = np.array([1,2,3,4,5])
y = np.array([0,2,3,4,6])
z = np.array([[1,2],[3,4]])#二维数组
np.mean(x==y)#返回条件成立的占比
Out[5]: 0.59999999999999998
np.mean(x)#均值
Out[6]: 3.0
np.mean(z)
Out[10]: 2.5
np.mean(z,axis=0)#按列求均值
Out[11]: array([ 2., 3.])
np.mean(z,axis=1)#按行求均值
Out[12]: array([ 1.5, 3.5])
numpy.mean()的几种用法
最新推荐文章于 2024-08-27 21:10:51 发布