[Numpy-discussion] Medians that ignore values

Eric Firing efiring@hawaii....
Fri Sep 19 13:01:13 CDT 2008

Pierre GM wrote:

>> It seems to me that there are pragmatic reasons
>> why people work with NaNs for missing values,
>> that perhaps shd not be dismissed so quickly.
>> But maybe I am overlooking a simple solution.
> nansomething solutions tend to be considerably faster, that might be one 
> reason. A lack of visibility of numpy.ma could be a second. In any case, I 
> can't but agree with other posters: a NaN in an array usually means something 
> went astray.

Additional reasons for using nans:

1) years of experience with Matlab, in which using nan for missing 
values is the standard idiom.
2) convenient interfacing with extension code in C or C++.

The latter is a factor in the present use of nan in matplotlib; using 
nan for missing values in an array passed into extension code saves 
having to pass and process a second (mask) array.  It is fast and simple.


More information about the Numpy-discussion mailing list