How can you estimate a typical reading with outliers and gaps?
nanmedian computes the median of the observations remaining after NaN values are omitted.
numpy.nanmedian in practice
Missing, one, two and one hundred give a median of two. Omitting gaps can still bias the sample if the device fails mostly at high temperatures.
import numpy as np
np.nanmedian([np.nan,1,2,100])Result 2.0
中文
少量异常且夹有缺测时如何取典型读数?
nanmedian 先排除 NaN,再从剩余观察值求中位数。
numpy.nanmedian 算例
读数为缺测、1、2、100 时返回 2。丢失的测量若集中发生在高温期,排除缺测仍会引入样本偏差。
import numpy as np
np.nanmedian([np.nan,1,2,100])结果 2.0