[Numpy-discussion] setting the same object value with a mask?
Mon Apr 16 10:50:24 CDT 2012
is there an elegant method for assigning the same value to several
indices in a ndarray? (in this case with dtype=object)
a = empty(4,'O') # object ndarray
x = [1,2,'f'] # the value to be set for some indicies - the value is not
a[array((True,False,True))] = x # works like put -> not what I want
a[array((0,2))] = x # same effect
print a # -> [1 None 2 None]
a,a = x,x # set explicitly - works
print a # -> [[1, 2, 'f'] None [1, 2, 'f'] None]
thanks for your help!
Thomas Tanner ------
More information about the NumPy-Discussion