Numpy mask based on if a value is in some other list
Accepted answer is right but currently numpy
's docs recommend using isin
function instead of in1d
Use numpy.in1d()
:
In [6]: np.in1d(a, [14, 16, 18])
Out[6]: array([False, False, False, True, False, True, False], dtype=bool)