
Listening minutes per listener
easyListening minutes per listener
Pandora Pandas Interview Question
Pandora bills advertisers on hours delivered, so the first number any campaign report needs is how long each listener actually spent in the app. The log records each play in milliseconds, which is useful to a machine and to nobody else.
Using the plays DataFrame, find each listener_id and their total listening time in minutes as minutes, rounded to 1 decimal place. Sort by minutes, 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 |
|---|---|---|---|---|
| 5001 | L01 | T100 | 2024-03-04 08:02:00 | 210000 |
| 5002 | L01 | T104 | 2024-03-04 08:06:00 | 185000 |
| 5003 | L01 | T100 | 2024-03-04 08:10:00 | 198000 |
| 5004 | L01 | T112 | 2024-03-04 09:15:00 | 240000 |
| 5005 | L01 | T104 | 2024-03-04 09:21:00 | 172000 |
| 5006 | L01 | T100 | 2024-03-04 18:40:00 | 205000 |
| 5007 | L01 | T118 | 2024-03-04 18:44:00 | 160000 |
| 5008 | L01 | T112 | 2024-03-04 18:49:00 | 233000 |
| 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 | minutes |
|---|---|
| L01 | 26.7 |
| L04 | 16.6 |
Explanation
L01 listened for 1,603,000 milliseconds across eight plays in the example, which is 26.7 minutes. L04 managed 16.6 across five. The longest listener comes first.
The example above is a small slice of the data. Your code runs against the full DataFrames.
Company
Pandora
Difficulty
easy
Topic
aggregations
Language
Pandas
Your code
Loading Python in the background. You can start writing.