方法一:

numpy 求均值,处理无效值和非零值

 

 参考自: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) 

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2023-03-20
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2021-11-29
  • 2021-08-27
相关资源
相似解决方案