Locked lesson.
About this lesson
In this video, we'll explain how to select data based on multiple conditional statements.
Exercise files
Download this lesson’s related exercise files.
Multiple Conditions.docx57.2 KB Multiple Conditions - Solution.docx
55.5 KB
Quick reference
Multiple Conditions
You can search using multiple conditionals using And (&) and Or (|) operators.
When to use
Use these when you want to search multiple conditionals.
Instructions
When you want to search more than one condition and want them all to be true:
my_df[(my_df["Total"] < 0) & (my_df["Wed"] < -1)]
When you want to search more than one condition and want either of them to be true:
my_df[(my_df["Total"] < 0) | (my_df["Wed"] < -1)]
Hints & tips
- AND: my_df[(my_df["Total"] < 0) & (my_df["Wed"] < -1)]
- OR: my_df[(my_df["Total"] < 0) | (my_df["Wed"] < -1)]
Lesson notes are only available for subscribers.