why do the following lines not work as I expect?
import numpy as np a = np.array([0,1,2,1,1]) a[a==1][1:] = 3 print a >>> [0 1 2 1 1] # I would expect [
It appears you simply can't do an assignment through a double-slice like that.
This works though:
a[numpy.where(a==1)[0][1:]] = 3