Hello, friend! Today's topic is Filtering Data. It's about focusing on the data that matters to us. We'll use pandas
, a Python library, to help us with this.
The goal? Master data filtering in pandas
. By the end, you'll be able to pick the necessary data from a big data set.
Filtering data in pandas
is like finding your favorite outfit in a wardrobe. The easiest way to filter data is by columns. Let's illustrate this using a DataFrame
of students' details.
The code above creates a DataFrame
and selects only the rows where the grade_level
is 7. Now, you have the data of the 7th-grade students. Note that it works exactly the same as the numpy's boolean selection. Let's recall how it works under the hood.
One of the magic tricks of pandas
is Boolean masking. is a True or False data type. "Mask" means to hide. A Boolean mask hides parts of your data based on it being True or False.
