I have a 2D array, a
, and another array, index_list
, that is a list of valid indices for that 2D array. The same index may appear more than once. I want to add one to that 2D array at every index that appears in the list of indices. If an index appears n times, I want to add one n times.
For example, given:
a = np.arange(9).reshape((3,3))
index_list = np.array([[0,0],[0,1],[2,2],[2,2]])
I want a function to return:
[[1,2,2],
[3,4,5],
[6,7,10]]
How can I do this with just numpy?