How can check for each row in a numpy array if it can be found in another array? So if I have
import numpy as np
a = np.array([[1, 2.6], [3, 4], [2.6, 1]])
b = np.array([[0, 0], [3, 4], [1, 2.6], [4.3, 4], [5, 5]])
I would like to get
array([True, True, False])
Obvioulsly
np.isin(a,b)
array([[ True, True],
[ True, True],
[ True, True]])
is not an answer and of course I can write something like
return_ = np.zeros(a.shape[0], dtype=bool)
for index, loc in enumerate(a):
for loc2 in b:
if np.allclose(loc, loc2):
return_[index] = True
break
but this is slow and looks horrible. I would prefer using proper numpy commands.