[Numpy-discussion] Can't set an element of a subset of an array, , ,

alan@ajackso... alan@ajackso...
Tue Dec 8 18:59:57 CST 2009


>2009/12/8  <alan@ajackson.org>:
>> Okay, I'm stuck. Why doesn't this work?
>>
>> In [226]: mask
>> Out[226]: array([False, False, False, ..., False, False, False], dtype=bool)
>> In [229]: mask[data['horizon']==i][2] = True
>
>mask[data['horizon']==i] creates a copy. mask[data['horizon']==i][2]
>assigns to the copy, which then gets thrown away.
>

Bummer. That was such a nice way to reach inside the data structure.


-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan@ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------


More information about the NumPy-Discussion mailing list