In pure, unvectorised, Python I can use,
>>> a = 9
>>> b = [5, 7, 12]
>>> a in b
False
I would like to do something similar for arrays in Numpy i.e.
>>> a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> b = np.array([5, 7, 12])
>>> a in b
np.array([False, False, False, False, True, False, True, False, False, False])
… although this does not work.
Is there a function or method that achieves this? If not what is the easiest way to do this?
You are looking for in1d: