This question has probably been asked somewhere before, but I couldn't find any after some search, hence posting here.
Say I have an array A and an index array idx. Let both the arrays be 2D for the time being.
import numpy as np
A = np.array([[3,3,4],
[4,5,4],
[3,4,5]])
idx = np.array([[1,1],
[2,1],
[1,0],
[0,0]])
Now I want to replace the corresponding elements in A based on the indexes in idx to 0.
Basically, I want to do A[idx]=0, which doesn't work.
How do I do this efficiently without running a loop?
Preferably, the proposed solution should be scalable to a higher dimensional (3D and above) arrays.