[SciPy-user] Masked array question

Pierre GM pgmdevlist@gmail....
Mon Jun 8 12:32:09 CDT 2009


On Jun 8, 2009, at 12:59 PM, Robert Ferrell wrote:

> I have a tuple of strings that I want to convert to an array of
> floats.  Some of the strings are empty, so I thought I could use a
> masked array to mask out the empty strings.  (In my application, empty
> string means no data, so ignore.)
>
> I tried:
>
> np.ma.masked_array(('1.', ' '), mask=(False, True), dtype=(np.float32,
> np.float32))

As indicated by the error message, it's a pb w/ numpy: it doesn't know  
how to process the '' for float. That you're using masked arrays  
unfortunately doesn't change anything to that
An idea is then to convert your '' to 'NaN' beforehand and use  
np.ma.fix_invalid on the results, or to define a mask as you wanted.



More information about the SciPy-user mailing list