Home » Pandas DataFrame.isin()

Pandas DataFrame.isin()

by Online Tutorials Library

Pandas DataFrame.isin()

The main task of the DataFrame.isin() method is to select the rows having a particular (or multiple) values in a particular column.

Syntax

Parameter

values : It can be DataFrame, Series, Iterable, or dict and returns a boolean value.

It returns a true value if all the labels match. If it consists of a Series, then it will be the index.

If it consists of a dict, then the keys must be the column names and must be matched.

If it consists of a DataFrame, then both the index and column labels must be matched.

Example1:

Output:

DataFrame  -----------  xy  0  1  3  1  2  7    DataFrame.isin(range(1,6))  -----------  xy  0  TrueTrue  1  TrueTrue  

Example2:

Output:

Use isin operator    EmpCodeNameOccupation                Date Of Join       Age  0  Emp001      Parker     Tester            2019-01-17     29  1  Emp002      Smith    Developer       2019-01-26     22  3  Emp004     Terry       Tester            2019-02-02   38  4  Emp005     Palin    Developer         2019-02-11   27    Multiple Conditions    EmpCode         Name      Occupation      Date Of Join    Age  0  Emp001      Parker     Tester           2019-01-17     29  3  Emp004      Terry       Tester           2019-02-02     38  

Next TopicDataFrame.loc[]

You may also like