Suppose you have two 2D arrays A and B, and you want to check, where a row of A is contained in B. How do you do this most efficiently using numpy?
E.g.
<
You can take advantage of the automatic broadcasting:
np.argwhere(np.all(a.reshape(3,1,-1) == b,2))
which results in
array([[0, 2], [1, 0]])
Note for floats you might want to replace the == with np.islclose()
==
np.islclose()