

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 7
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
Even after nulls and type conversions, data still isn't clean if the values are impossible. For example, product ratings can't exceed 5 stars, and order totals can't be negative.
Data validation has to start with: "Do these values match my expectations?". Just use boolean masks to find rows breaking the rules, for example, using the between() method:
valid_ratings = df["rating"].between(1, 5)
num_valid_ratings = int(valid_ratings.sum())
Complete the validate_device_data function. It accepts a DataFrame with temperature and battery_level columns, then validates the temperature (-40 to 200) and battery_level (0 to 100) are within range and returns a validation report dictionary.