![]() |
VOOZH | about |
In this article, we will explore the Pandas DataFrame.isin() method provided by the Pandas library in Python. Python is widely recognized for its proficiency in data analysis, largely attributed to its exceptional ecosystem of data-centric packages. Among these, Pandas stands out as an essential tool that significantly simplifies tasks related to data import and analysis.
Syntax: DataFrame.isin(values)
Parameters: values: iterable, Series, List, Tuple, DataFrame or dictionary to check in the caller Series/Data Frame.
Return Type: DataFrame of Boolean of Dimension.
To download the CSV file used, Click Here.
The DataFrame.isin() method in Pandas is a powerful tool for filtering and selecting data within a DataFrame based on specified conditions. It allows you to create boolean masks to identify rows where the values in one or more columns match certain criteria. Let's delve into the details of the isin() method
In the following example, Rows are checked and a boolean series is returned which is True wherever Gender="Male". Then the series is passed to the data frame to see new filtered data frame.
Output
As shown in the output image, only Rows having gender = "Male" are returned.
In the following example, the data frame is filtered on the basis of Gender as well as Team. Rows having Gender="Female" and Team="Engineering", "Distribution" or "Finance" are returned.
Output
As shown in the output image, Rows having Gender="Female" and Team="Engineering", "Distribution" or "Finance" are returned.