[Numpy-discussion] Medians that ignore values

Anne Archibald peridot.faceted@gmail....
Thu Sep 18 23:18:15 CDT 2008


2008/9/18 David Cournapeau <david@ar.media.kyoto-u.ac.jp>:
> Anne Archibald wrote:
>>
>> 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 was referring to the fact that if you have nan in your array, you
> should use nanmean if you want to ignore them correctly. Now, the
> different behavior depending on the order of items in the arrays is
> indeed buggy, I thought this was fixed.

That was in amax/amin. Pretty much every other function that does
comparisons needs to be fixed to work with nans. In some cases it's
not even clear how: where should a sort put the nans in an array? I
suppose some enterprising soul should write up a fileful of tests
making sure that all numpy's functions do something sane with arrays
containing nans...

Anne


More information about the Numpy-discussion mailing list