I think this might be a numpy bug:
np.percentile([0,1,np.inf], 50) Out[63]: nan
a
np.median([0, 1, np.inf]) Out[65]: 1.0
Instead of just taking a value at index 1, it takes values at indexes 1 and 2 with weights 1 and 0. Thus, this results in 0 * inf .
In your case, the result should be 2.33 (try, for example, df.iloc[5,0] = 1e10 ).
source share