Suppose we have the following 2d arrays:
>>> A
array([[1, 1],
[2, 2],
[3, 1]])
>>> B
array([[2, 1],
[1, 2],
[3, 1],
[4, 2]])
I want to test the membership of the rows of A in the rows of B. For a single row of A we can test it's membership in B with:
np.any(np.all(A[index] == B, axis=1))
I want to do this for all rows of A at once without looping over the indices. The result should be:
desired_result = array([False, False, True])
How do we retrieve this result in a broadcasted way (without looping over rows of A)?