I have 2D numpy.ndarray() and indices to be replaced.
idx = np.array([[1, 0],
[2, 1],
[2, 3],])
array = np.array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]])
Which I want to have is like following array.
np.array([[0, 0, 0, 0],
[1, 0, 0, 0],
[0, 1, 0, 1]])
Elements where specified by idx in the array is replaced with an arbitrary value.
>Solution :
If I understand you correctly you want to index the array by 2D array idx:
array[idx[:, 0], idx[:, 1]] = 1
print(array)
Prints:
[[0 0 0 0]
[1 0 0 0]
[0 1 0 1]]