

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: Welcome to Pandas
incomplete
2: Data Types
incomplete
3: Data Analytics Workflow
incomplete
4: Dates and Times
incomplete
5: Datetime Math
incomplete
6: Comparing Dates
incomplete
7: List Comprehensions
incomplete
8: Dictionary Comprehensions
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Before you manipulate data, you need to know what kind of data you're looking at.
If you think a value is a number but it's actually a string, your calculations break. If you think a field always holds a string but sometimes it's None, your cleaning logic breaks. Here's a quick refresher on the Python types you'll most often encounter in data work:
int – whole numbers like 42float – decimal numbers like 3.14str – text like "hello"bool – True or Falselist – ordered collection of valuestuple – ordered collection that shouldn't changeset – unordered collection of unique valuesdict – key-value pairsNoneType – i.e. None, representing the absence of a valueRaw data almost never arrives in the exact type you want. For example:
movie = {"title": "Stranger Things", "rating": "8.7", "seasons": "4"}
Numbers as strings?! Unfortunately, this is common. If you're not careful, you might write:
boosted_rating: float = movie["rating"] + 0.5
Which will fail on a string. You need to convert the type first:
rating = float(movie["rating"])
boosted_rating: float = rating + 0.5
SnackStack's kitchen sensors are sending readings with numbers stored as strings... classic appliance behavior.
Complete the clean_sensor_reading function. It accepts a dictionary of "raw" string-based sensor data and should return a new dictionary with the correct types.