Check whether values are contained in Series.

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

param 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.

New in version 0.18.1.

Support for values as a set.


Series Series of booleans indicating if each element is in values.

  • If values is a string


  • This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff

    between staying in JIT-region with that function or going back to interpreter mode.


Check whether values are contained in Series.
import numpy as np
import pandas as pd
from numba import njit

def series_isin():
    s = pd.Series([4, np.nan, 2, 1])

    return s.isin([4, 1])  # Expect series of True, False, False, True

$ python ./series/
0     True
1    False
2    False
3     True
dtype: bool

See also


Equivalent method on DataFrame.