I want to get the indices of the intersecting rows of a main numpy 2d array A, with another one B.
A=array([[1, 2],
[3, 4],
[5, 6],
[7, 8],
[9, 10]])
B=array([[1, 4],
[1, 2],
[5, 6],
[6, 3]])
result=[0,2]
Where this should return [0,2] based on the indices of array A.
How can this be done efficiently for 2d arrays?
Thank you!
edit
I have tried the function:
k[np.in1d(k.view(dtype='i,i').reshape(k.shape[0]),k2.view(dtype='i,i').
reshape(k2.shape[0]))]
from Implementation of numpy in1d for 2D arrays? but I get a reshape error. My datatype is floats (with two decimals). Moreover, I also tried with sets but the performance is quite slow.