

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
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
I often find myself needing to check the length of a string column. For example, a username should be at least 5 characters long, but perhaps no more than 20.
df = df[(df["username"].str.len() >= 5) & (df["username"].str.len() < 20)]
Alternatively, a movie_id might always be a fixed length of 32 characters:
df = df[df["movie_id"].str.len() == 32]
Complete the clean_device_ids function. It accepts a DataFrame with a fixed device_id column, then trims whitespace, removes empty strings, filters out IDs shorter than 3 characters, and returns a cleaned DataFrame.