5. Filtering
Types of Filtering
iloc
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Getting any row in DataFrame
Getting multiple rows in DataFrame
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Slicing multiple rows in DataFrame
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Getting single value in DataFrame
Getting random rows and random columns in DataFrame
Customer ID
Age
Quantity
Getting slicing of rows and columns in DataFrame
Age
Product Category
How would you get a single column?
loc
Filter data where Gender is Male
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Filter data where Age is greater than 50
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Multiple conditions in filtering
& - Filter data where Gender is Male and Age is greater than 50
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
& - Filter data where Age is between 20 to 30
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
| - Filter data where Category is Clothing or Electronics
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
!= - Filter where data is not equal to Electronics
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
~ - Filter where data is not equal to Electronics
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
~ - Filter data where Gender is not male and Category is not electronics
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
isin()
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
between()
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
reset_index()
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Update records
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Customer ID
Gender
Age
Product Category
Quantity
Price per Unit
Assignments:
50 Pandas Filtering & Update Questions
🔸 Basic Filtering
🔸 Multiple Conditions
🔸 Using .isin() and .between()
.isin() and .between()🔸 Using .iloc for positional filtering
.iloc for positional filtering🔸 Using .loc for conditional filtering
.loc for conditional filtering🔸 Updating Records using .loc
.locLast updated