[Numpy-discussion] Re: Using Reduce with Multi-dimensional Masked array
reggie at merfinllc.com
Thu Nov 29 10:36:01 CST 2001
> That raises the question of how to determine a count of valid values
> in a masked array. Can I assume that I can do 'math' on the mask
> array itself, for example to sum along a given axis and have the
> masked cells add up?
> In my original example, I would expect a sum along the second axis
> to return [0,0,0,2,0]. Can I rely on this? I would suggest that a
> .count operator would be very useful in working with masked arrays
> (count valid and count masked).
Actually masked arrays already have a count method that does what you
Python 2.2b2 (#26, Nov 16 2001, 11:44:11) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pydoc import help
>>> import MA
>>> x = MA.arange(10)
Help on method count in module MA.MA:
count(self, axis=None) method of MA.MA.MaskedArray instance
Count of the non-masked elements in a, or along a certain axis.
More information about the Numpy-discussion