[Numpy-discussion] more recfunctions, structured array help
Tue Dec 8 15:38:43 CST 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