[Numpy-discussion] Masked array usage
Robert Ferrell
ferrell at diablotech.com
Thu Nov 27 10:54:09 EST 2008
Sweet. So simple. That works great.
thanks,
-robert
On Nov 27, 2008, at 8:41 AM, Angus McMorland wrote:
> 2008/11/27 Robert Ferrell <ferrell at diablotech.com>:
>> I have a question about assigning to masked arrays. a is a len ==3
>> masked array, with 2 unmasked elements. b is a len == 2 array. I
>> want to put the elements of b into the unmasked elements of a. How
>> do
>> I do that?
>>
>> In [598]: a
>> Out[598]:
>> masked_array(data = [1 -- 3],
>> mask = [False True False],
>> fill_value=999999)
>>
>>
>> In [599]: b
>> Out[599]: array([7, 8])
>>
>> I'd like an operation that gives me:
>>
>> masked_array(data = [7 -- 8],
>> mask = [False True False],
>> fill_value=999999)
>>
>> Seems like it shouldn't be that hard, but I can't figure it out. Any
>> suggestions?
>
> How about:
>
> c = a.copy()
> c[~a.mask] = b
>
> Angus.
> --
> AJC McMorland
> Post-doctoral research fellow
> Neurobiology, University of Pittsburgh
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list