I have a indices array like this:
idx = np.array([3,4,1], [0,0,0], [1,4,1], [2,0,2]]
And an array of zeros A with shape 4x5
I would like to make all the indices in idx of A to be 1
For the above example, the final array should be:
[[0,1,0,1,1], # values at index 3,4,1 are 1
[1,0,0,0,0], # value at index 0 is 1
[0,1,0,0,1], # values at index 1,4 are 1
[1,0,1,0,0]] # values at index 0,2 are 1
How can this be done in numpy?