In this exercise, you will learn to filter data based on multiple conditions simultaneously. This helps in narrowing down specific customer segments efficiently.

Instructions:

  1. Filter Customers Aged Between 20 and 40:

  2. Filter Customers Older Than 30 and Spending Over $90:

Python Code:

#1.Filter Customers Aged Between 20 and 40:

import pandas as pd

age_filtered = df[(df['Age'] >= 20) & (df['Age'] <= 40)]

age_filtered.head()


# 2. Filter rows where 'Age' > 30 and 'Purchase Amount (USD)' > 100

import pandas as pd

combined_conditions = df[(df['Age'] > 30) & (df['Purchase Amount (USD)'] > 90)]

combined_conditions.head()