[Numpy-discussion] Medians that ignore values
Anne Archibald
peridot.faceted@gmail....
Thu Sep 18 21:54:49 CDT 2008
2008/9/18 David Cournapeau <david@ar.media.kyoto-u.ac.jp>:
> 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).
I don't think I agree:
In [4]: np.median([1,3,nan])
Out[4]: 3.0
In [5]: np.median([1,nan,3])
Out[5]: nan
In [6]: np.median([nan,1,3])
Out[6]: 1.0
I think the expected behaviour would be for all of these to return nan.
Anne
More information about the Numpy-discussion
mailing list