I’m scratching my head around a small problem but I can’t find a vectorized 
solution.
I have 2 arrays A and B and I would like to get the indices (relative to B) of 
elements of A that are in B:

>>> A = np.array([2,0,1,4])
>>> B = np.array([1,2,0])
>>> print (some_function(A,B))
[1,2,0]

# A[0] == 2 is in B and 2 == B[1] -> 1
# A[1] == 0 is in B and 0 == B[2] -> 2
# A[2] == 1 is in B and 1 == B[0] -> 0

Any idea ? I tried numpy.in1d with no luck.


Nicolas

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to