[Numpy-discussion] more recfunctions, structured array help
Pierre GM
pgmdevlist at gmail.com
Tue Dec 8 16:38:43 EST 2009
On Dec 8, 2009, at 3:42 PM, John [H2O] wrote:
> I see record arrays don't have a masked_where method. How can I achieve the
> following for a record array:
>
> cd.masked_where(cd.co == -9999.)
>
> Or something like this.
masked_where is a function that requires 2 arguments.
If you try to mask a whole record, you can try something like
>>> x = ma.array([('a',1),('b',2)],dtype=[('','|S1'),('',float)])
>>> x[x['f0']=='a'] = ma.masked
For an individual field, try something like
>>>x['f1'][x['f1']=='b'] = ma.masked
Otherwise, ma.masked_where doesn't work with structured arrays (yet, that's a bug I just find out)
More information about the NumPy-Discussion
mailing list