I have two arrays:
A = np.array([[3, 1], [4, 1], [1, 4]])
B = np.array([[0, 1, 5], [2, 4, 5], [2, 3, 5]])
Is it possible to use numpy.isin
rowwise for 2D arrays? I want to check if A[i,j]
is in B[i]
and return this result into C[i,j]
. At the end I would get the following C
:
np.array([[False, True], [True, False], [False, False]])
It would be great, if this is also doable with the ==
operator, then I could use it also with PyTorch.
Edit: I also considered check for identical rows in different numpy arrays. The question is somehow similar, but I am not able to apply its solutions to this slightly different problem.