Python Numpy Structured Array (recarray) assigning values into slices
- by user368877
Hi,
The following example shows what I want to do:
>>> test
rec.array([(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)],
dtype=[('ifAction', '|i1'), ('ifDocu', '|i1'), ('ifComedy', '|i1')])
>>> test[['ifAction', 'ifDocu']][0]
(0, 0)
>>> test[['ifAction', 'ifDocu']][0] = (1,1)
>>> test[['ifAction', 'ifDocu']][0]
(0, 0)
So, I want to assign the values (1,1) to test[['ifAction', 'ifDocu']][0]. (Eventually, I want to do something like test[['ifAction', 'ifDocu']][0:10] = (1,1), assigning the same values for for 0:10. I have tried many ways but never succeeded. Is there any way to do this?
Thank you,
Joon