I have an array b containing indices of an array a. I want to insert values of another array c in the array b with same indices.
import numpy as np
a1=np.array([[1, 3, 5, 2, 3],[7, 6, 5, 2, 4],[2, 0, 5, 6, 4]])
a=a1.argsort()[:,:2]
## this will create an array with indices of 2 smallest values of a1
a
[[0 3]
[3 4]
[1 0]]
b=np.array([[1],[2],[3],[4],[5],[6]])
now I want to replace value 0 in a with 1 in b ; 3 with 4 and so on
i tried using:
[a[index]]=b[index]
but its obviously not the right way as array a handles these indices as values
please help
c, but don't show it in your example. Could you show what you want the output of the operation to be in your example?