方法一:

参考自:https://blog.csdn.net/iteapoy/article/details/85139485
方法二:
将零值转为 np.nan,无效值,使用np.nanmean()函数计算
例如
1 temp=np.array([5,3,7,0,0])
2 temp = np.where(temp>0,temp,np.nan)
3 np.nanmean(temp)
方法一:

参考自:https://blog.csdn.net/iteapoy/article/details/85139485
方法二:
将零值转为 np.nan,无效值,使用np.nanmean()函数计算
例如
1 temp=np.array([5,3,7,0,0])
2 temp = np.where(temp>0,temp,np.nan)
3 np.nanmean(temp)
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。