pandas.Series.isin
-
Series.isin(values)[source] -
Return a boolean
Seriesshowing whether each element in theSeriesis exactly contained in the passed sequence ofvalues.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 alistof one element.New in version 0.18.1.
Support for values as a set
Returns: isin : Series (bool dtype)
Raises: TypeError
- If
valuesis a string
See also
Examples
>>> s = pd.Series(list('abc')) >>> s.isin(['a', 'c', 'e']) 0 True 1 False 2 True dtype: boolPassing a single string as
s.isin('a')will raise an error. Use a list of one element instead:>>> s.isin(['a']) 0 True 1 False 2 False dtype: bool
- If
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.21.1/generated/pandas.Series.isin.html