Suppose I have two arrays, x
and y
, where y
is a subset of x
:
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
y = [3, 4, 7]
I want to return an array like:
ret = [False, False, True, True, False, False, True, False, False]
If y
were just a single number it would be easy enough (x == y
), but I tried the equivalent x in y
and it didn't work. Of course, I could do it with a for loop, but I'd rather there was a neater way.
I've tagged this Pandas since x
is actually a Pandas series (a column in a dataframe). y
is a list, but can be made to be a NumPy array or Series if needed.