

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Multiple Conditions
incomplete
2: The Not Operator
incomplete
3: Filter Methods
incomplete
4: Binning
incomplete
5: String Operations
incomplete
6: Filtering With String Methods
incomplete
7: Sorting Data
incomplete
8: More Sorting
incomplete
9: Conditional Updates
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
What about negating a boolean mask? In Pandas, you use the ~ operator, though direct comparisons can still use !=.
# Tracks that are NOT available
unavailable = df[~(df["status"] == "available")]
# Available tracks that are NOT in the US market
available_not_us = df[(df["status"] == "available") & ~(df["market"] == "US")]
The ~ flips boolean values – True becomes False and vice versa.
Just like & and |, wrap the thing you're negating in parentheses: ~(df["market"] == "US"). It keeps the precedence unambiguous.
The West Coast SnackStack team wants to monitor every device outside their own region – but only the ones that are still reachable.
Complete the get_devices_outside_region function. It accepts a DataFrame of devices and a region, and returns only the devices outside that region that are still online.