pyspark.pandas.Series.isin#

Series.isin(values)#

Check whether values are contained in Series or Index.

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

Parameters
valuesset or list-like

The sequence of values to test.

Returns
isinSeries (bool dtype) or Index (bool dtype)

Examples

>>> s = ps.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

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
>>> s.rename("a").to_frame().set_index("a").index.isin(['lama'])  
Index([True, False, True, False, True, False], dtype='bool', name='a')