[Numpy-discussion] Concepts for masked/missing data
Sat Jun 25 13:58:56 CDT 2011
On Sat, Jun 25, 2011 at 12:17 PM, Wes McKinney <email@example.com> wrote:
> Agree. My basic observation about numpy.ma is that it's a finely
> crafted solution for a different set of problems than the ones I have.
> I just don't want the same thing to happen here so I'm stuck writing
> code (like I am now) that looks like
> mask = y.mask
> the_sum = y.sum(axis)
> the_count = mask.sum(axis)
> the_sum[the_count == 0] = nan
Yeah, you are expecting NaN behavior there, in which case, using NaNs
without masks is fine. But, for a general solution, you might want to
consider that masked_array provides a "recordmask" as well as a mask.
Although, the documentation is very lacking, and using masked arrays with
record arrays seems very clumsy, but that is certainly something that could
get cleaned up.
Also, as a cleaner version of your code:
the_sum = y.sum(axis)
the_sum.mask = np.any(y.mask, axis)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion