Say I have two arrays, same size, no duplicates, each item in array 1 is in array2:
arr1 = np.array([100,200,50,150])
arr2 = np.array([150,200,100,50])
What is the best way to find an index map inds such that arr2[inds] returns arr1?
My current solution works, but I was wondering if there was something more numpyish that would be more efficient on large arrays:
ind21 = map(lambda x:np.abs(x-arr2).argmin(),arr1)
In [57]: arr1,arr2[ind21]
Out[57]: (array([100, 200, 50, 150]), array([100, 200, 50, 150]))