What is the denominator when some sensors skip a day?
nanmean skips NaN and divides by the number of observations contributing numeric values.
numpy.nanmean in practice
Readings two, missing and six average to four. An entirely missing group yields NaN, so retain the valid count alongside the chart.
import numpy as np
np.nanmean([2,np.nan,6])Result 4.0
中文
每天少报几个传感器时,平均值的分母是多少?
nanmean 忽略 NaN,以实际有数值的项目数计算均值。
numpy.nanmean 算例
三站读数 2、缺测、6,平均为 4。整组缺测时结果仍是 NaN,因此监控图应同时记录有效样本数。
import numpy as np
np.nanmean([2,np.nan,6])结果 4.0