AnalystPath

Listeners Who Beat Their Own Average

PandasEasyJunior level~10 min

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.

listen_sessions
listener_idepisode_titleminutes_played
1Deep Sea Mysteries42
1City Soundscapes18
1Quiet Mornings60
2Startup Diaries25
2Code & Coffee30

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_sessions

Solve 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

Related Pandas questions