[Numpy-discussion] Masked array usage
Angus McMorland
amcmorl@gmail....
Thu Nov 27 09:41:22 CST 2008
2008/11/27 Robert Ferrell <ferrell@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
More information about the Numpy-discussion
mailing list