Remove masked elements from an array

Tim Churches tchur at optushome.com.au
Mon Apr 29 17:13:36 EDT 2002


PoulsenL at capecon.com wrote:
> 
> I have a Numeric array with missing elements from which I wish to calculate
> a histogram.  However, in order to do so I must first remove the 'None'
> values from the array.  I have a kludgy solution, but I was wondering if
> someone could point me in the right direction on what is the proper method
> of collapsing a masked array to just the non-masked values.

Loren,

Use the .compressed() method on the masked array. It is documented in
table 6 in the MA section of the NumPy documentation.

Tim C





More information about the Python-list mailing list