We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Data Validation

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())

Assignment

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.