I'm wondering if there is a better way of assigning values from a numpy array to a 2D numpy array based on an index array.
arr1 = np.array([1, 1, 1])
arr2 = np.array([1, 1, 1])
arr3 = np.array([1, 1, 1])
index = np.array([1, 2, 1])
values = np.array([0, 0, 0])
for idx, arr_x in enumerate(newest):
arr_x[index[idx]] = values[idx]
Right now I'm doing it like this to get an result like:
[[1 0 1]
[1 1 0]
[1 0 1]]
I thought newest[:, index] = values
should work but it's not.
Does anybody know how to do this? I'm sure there is a better way. Thanks in advance.