
Share of plays cut short
mediumShare of plays cut short
Pandora Pandas Interview Question
A Pandora listener who skips most of what they are served is being recommended the wrong music, and they churn long before they complain. The signal is a play that ends early: anything under three minutes counts as cut short.
Using the plays DataFrame, find each listener_id, their number of plays as plays_total, and the percentage of those cut short as short_pct, rounded to 1 decimal place. Sort by short_pct, highest first. Assign the answer to result.
Asked of
- Data Analyst
- Business Analyst
- BI Analyst
- Product Analyst
- Analytics Engineer
- Data Scientist
playsDataFrame30 rows
| Column Name | Type |
|---|---|
| play_id | int64 |
| listener_id | str |
| track_id | str |
| played_at | str |
| ms_played | int64 |
playsExample Input
| play_id | listener_id | track_id | played_at | ms_played |
|---|---|---|---|---|
| 5009 | L02 | T100 | 2024-03-04 07:30:00 | 120000 |
| 5010 | L02 | T121 | 2024-03-04 07:34:00 | 250000 |
| 5011 | L02 | T121 | 2024-03-04 07:39:00 | 248000 |
| 5012 | L02 | T121 | 2024-03-04 07:45:00 | 251000 |
| 5013 | L02 | T104 | 2024-03-04 12:05:00 | 90000 |
| 5014 | L02 | T118 | 2024-03-04 12:12:00 | 215000 |
| 5015 | L02 | T121 | 2024-03-04 21:02:00 | 244000 |
| 5016 | L02 | T100 | 2024-03-04 21:08:00 | 118000 |
| 5026 | L04 | T100 | 2024-03-04 11:00:00 | 204000 |
| 5027 | L04 | T100 | 2024-03-04 11:05:00 | 201000 |
| 5028 | L04 | T104 | 2024-03-04 15:45:00 | 178000 |
| 5029 | L04 | T118 | 2024-03-04 15:52:00 | 162000 |
| 5030 | L04 | T121 | 2024-03-04 15:58:00 | 249000 |
Example Output
| listener_id | plays_total | short_pct |
|---|---|---|
| L04 | 5 | 40 |
| L02 | 8 | 37.5 |
Explanation
L04 played five tracks and two of them stopped before three minutes, which is 40 percent. L02 played eight and three were cut short, which is 37.5 percent, so L04 sorts first.
The example above is a small slice of the data. Your code runs against the full DataFrames.
Company
Pandora
Difficulty
medium
Topic
conditional logic
Language
Pandas
Your code
Loading Python in the background. You can start writing.