Section 1 - Instruction

Last time, we filtered data with one rule. But what if your question is more specific? For example, finding customers who are over 30 and live in London. This requires combining multiple conditions to narrow down your results.

Engagement Message

What insights become possible when you can combine multiple criteria?

Section 2 - Instruction

To find rows that meet both Condition A AND Condition B, we use the & (AND) operator. This tells Pandas to only keep rows where both conditions are true. It's how you narrow your search to be more precise.

Engagement Message

If you filter for Department == 'Sales' & Region == 'West', would a sales employee from the 'East' region be included?

Section 3 - Instruction

Let's see a real example. To find expensive electronics, you could write: df[(df['Category'] == 'Electronics') & (df['Price'] > 500)]

This code selects only the rows that are both in the 'Electronics' category and cost more than $500.

Engagement Message

Can you think of another real-world question that would require an & filter?

Section 4 - Instruction

Here's the most important syntax rule: when using & or |, each individual condition must be wrapped in its own set of parentheses . This ensures Pandas evaluates each condition correctly before combining them.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal