modin.pandas.Series.isin¶

Series.isin(values: Union[set, list, tuple, ndarray]) → Series[source]¶

Whether elements in Series are contained in values.

Return a boolean Series showing whether each element in the Series matches an element in the passed sequence of values.

Caution

Snowpark pandas deviates from pandas here with respect to NA values: when the value is considered NA or values contains at least one NA, None is returned instead of a boolean value.

Parameters:

values (set or list-like) – The sequence of values to test. Passing in a single string will raise a TypeError. Instead, turn a single string into a list of one element.

Returns:

Series of booleans indicating if each element is in values.

Return type:

Series

Examples

>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
...                'hippo'], name='animal')
>>> s.isin(['cow', 'lama'])
0     True
1     True
2     True
3    False
4     True
5    False
Name: animal, dtype: bool
Copy

To invert the boolean values, use the ~ operator:

>>> ~s.isin(['cow', 'lama'])
0    False
1    False
2    False
3     True
4    False
5     True
Name: animal, dtype: bool
Copy

Passing a single string as s.isin('lama') will raise an error. Use a list of one element instead:

>>> s.isin(['lama'])
0     True
1    False
2     True
3    False
4     True
5    False
Name: animal, dtype: bool
Copy
>>> pd.Series([1]).isin(['1'])
0    False
dtype: bool
Copy
>>> pd.Series([1, 2, None]).isin([2])
0    False
1     True
2     None
dtype: object
Copy

Note

See pandas API documentation for pandas.Series for more.