[Numpy-discussion] Medians that ignore values

David Cournapeau david@ar.media.kyoto-u.ac...
Thu Sep 18 20:22:11 CDT 2008

Peter Saffrey wrote:
> Is this the correct behavior for median with nan? 

That's the expected behavior, at least :) (this is also the expected
behavior of most math packages I know, including matlab and R, so this
should not be too surprising if you have used those).

> Is there a fix for 
> this or am I going to have to settle with using lists?

You can use nanmean (from scipy.stats):

>>> stats.nanmedian(np.array([1, np.nan, 3, 9]))



More information about the Numpy-discussion mailing list