

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
Not enough gems
Cost: 6 gems
1: Data Cleaning
incomplete
2: Handling Missing Values
incomplete
3: Handling Duplicates
incomplete
4: Type Normalization
incomplete
5: Converting Types
incomplete
6: Cleaning Dates
incomplete
7: Working With Date Values
incomplete
8: Data Validation
incomplete
9: String Length
incomplete
10: Validation Summary
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
If there isn't a trustworthy fix for invalid rows, sometimes it's best just to remove them:
valid_mask = df["rating"].between(1, 5)
df_clean = df[valid_mask]
That said, silently dropping bad rows can hide real problems. I like to add a validation summary so that the damage remains visible:
invalid_mask = ~df["rating"].between(1, 5)
validation_summary = {
"total_rows": len(df),
"invalid_ratings": invalid_mask.sum(),
}
Complete the remove_invalid_device_data function. It accepts a DataFrame with temperature and battery_level columns. Return a cleaned DataFrame with only valid records and a validation summary dictionary.