

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
Once a column is a datetime, you can ask time-based questions.
What hour do orders spike?
Which quarter had the most signups?
Which weekday is cursed has fewer sales?
Pandas exposes date helpers through the .dt accessor, so you can pull out a Series of date parts directly:
df["signup_year"] = df["signup_at"].dt.year # 2024
df["signup_month"] = df["signup_at"].dt.month # 1 = January
df["signup_day"] = df["signup_at"].dt.day # 15
df["signup_hour"] = df["signup_at"].dt.hour # 0-23
df["signup_weekday"] = df["signup_at"].dt.dayofweek # 0 = Monday
df["signup_quarter"] = df["signup_at"].dt.quarter # 2 (April-June)
df["signup_day_name"] = df["signup_at"].dt.day_name() # "Monday"SnackStack's analytics team is tired of eyeballing raw timestamps in their activity reports. They want a short, human-friendly label on every device reading, like "Monday, Q1 2024".
Complete the label_events function. It accepts a DataFrame with a datetime timestamp column and returns a copy with a single new event_label column – a string that stitches a few date parts together into your own custom format.
For each row, build the label as "<weekday>, Q<quarter> <year>". For example, a timestamp of 2024-01-15 10:30:00 (a Monday) becomes "Monday, Q1 2024".