pby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.isin  #

DataFrame.  isin  (  _ values  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L12374-L12486) #

    

Whether each element in the DataFrame is contained in values.

Parameters  :

    

**values** iterable, Series, DataFrame or dict

    

The result will only be true at a location if all the labels match. If  values
is a Series, thatâs the index. If  values  is a dict, the keys must be the
column names, which must match. If  values  is a DataFrame, then both the
index and column labels must match.

Returns  :

    

DataFrame

    

DataFrame of booleans showing whether each element in the DataFrame is
contained in values.

See also

[ ` DataFrame.eq  ` ](pandas.DataFrame.eq.html#pandas.DataFrame.eq
"pandas.DataFrame.eq")

    

Equality test for DataFrame.

[ ` Series.isin  ` ](pandas.Series.isin.html#pandas.Series.isin
"pandas.Series.isin")

    

Equivalent method on Series.

[ ` Series.str.contains  `
](pandas.Series.str.contains.html#pandas.Series.str.contains
"pandas.Series.str.contains")

    

Test if pattern or regex is contained within a string of a Series or Index.

Examples

    
    
    >>> df = pd.DataFrame({'num_legs': [2, 4], 'num_wings': [2, 0]},
    ...                   index=['falcon', 'dog'])
    >>> df
            num_legs  num_wings
    falcon         2          2
    dog            4          0
    

When ` values  ` is a list check whether every value in the DataFrame is
present in the list (which animals have 0 or 2 legs or wings)

    
    
    >>> df.isin([0, 2])
            num_legs  num_wings
    falcon      True       True
    dog        False       True
    

To check if ` values  ` is _not_ in the DataFrame, use the ` ~  ` operator:

    
    
    >>> ~df.isin([0, 2])
            num_legs  num_wings
    falcon     False      False
    dog         True      False
    

When ` values  ` is a dict, we can pass values to check for each column
separately:

    
    
    >>> df.isin({'num_wings': [0, 3]})
            num_legs  num_wings
    falcon     False      False
    dog        False       True
    

When ` values  ` is a Series or DataFrame the index and column must match.
Note that âfalconâ does not match based on the number of legs in other.

    
    
    >>> other = pd.DataFrame({'num_legs': [8, 3], 'num_wings': [0, 2]},
    ...                      index=['spider', 'falcon'])
    >>> df.isin(other)
            num_legs  num_wings
    falcon     False       True
    dog        False      False
    

[ __ previous  pandas.DataFrame.get  ](pandas.DataFrame.get.html "previous
page") [ next  pandas.DataFrame.where  __ ](pandas.DataFrame.where.html "next
page")

__ On this page

  * ` DataFrame.isin()  `

[ __ Show Source ](../../_sources/reference/api/pandas.DataFrame.isin.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.