Project 19: Session Duration Summary
Data Analyst
Builds on these lessons
Current Task
Objective
.agg() applies several aggregate functions at once to a grouped column, returning one column per function.
Task: group sessions by user and compute both the mean and max duration in one .agg() call.
index.py
import pandas as pd
sessions = pd.DataFrame({'user': ['a', 'a', 'b'], 'duration': [30, 45, 20]})
summary = sessions.groupby('user')['duration'].agg(['mean', 'max'])
print(summary)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview