Listeners Who Beat Their Own Average
Problem
You are given one DataFrame `listen_sessions` (loaded from `listen_sessions.csv`), where each row is a listening session with columns `listener_id`, `episode_title`, and `minutes_played`. A listener is engaged when they have at least 3 recorded sessions AND at least one of those sessions ran longer than that listener's own average session length. For every engaged listener, return their `listener_id`, their total number of sessions as `session_count`, and their average minutes per session as `avg_minutes` rounded to 2 decimals. Order by `avg_minutes` from highest to lowest, breaking ties by `listener_id` ascending.
Input data
Example rows — the live problem includes the full dataset.
| listener_id | episode_title | minutes_played |
|---|---|---|
| 1 | Deep Sea Mysteries | 42 |
| 1 | City Soundscapes | 18 |
| 1 | Quiet Mornings | 60 |
| 2 | Startup Diaries | 25 |
| 2 | Code & Coffee | 30 |
Expected output
Your answer should return 2 rows with the columns listener_id, session_count, avg_minutes.
Starter code (Pandas (Python))
import pandas as pd
def find_above_average_listeners(listen_sessions) -> pd.DataFrame:
# Your code here
return listen_sessionsSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock