Assume I have the following array
arr = np.array([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]])
And an array with indices, that has as many elements as arr has rows , i.e. idx.shape[0] == arr.shape[0]
idxs = np.array([2, 1, 0])
I want all elements, after that index that appears in idxs to be set to zero in arr:
desired_result = np.array([[1, 2, 3, 0], [2, 3, 0, 0], [3, 0, 0, 0]])
Since I have to do this for more than 10k elements, I want to avoid a for-loop