Performing Filtering

Learn how to filter data using different built-in methods of Python.

Method 1: Boolean indexing

We use boolean indexing to filter a DataFrame by creating a boolean array that specifies the criteria we want to use to select the rows. Then, we use that boolean array to index the DataFrame and select only the rows that meet the criteria.

In the following example, we'll use boolean indexing to select only the rows in the DataFrame where the value in the COUNTRY column is UNITED KINGDOM.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy