Agent Resolution Rate
Problem
A help desk tracks its support agents and the outcome of every ticket they handle.
You are given two DataFrames.
`agents` — one row per agent:
| Column | Type |
|----------|----------|
| agent_id | int |
| hired_at | datetime |
`agent_id` is unique. Each row records when an agent was hired.
`tickets` — one row per ticket:
| Column | Type |
|-----------|----------|
| agent_id | int |
| opened_at | datetime |
| outcome | text |
`(agent_id, opened_at)` is unique. `outcome` is either `'resolved'` or `'escalated'`.
An agent's **resolution rate** is the number of `'resolved'` tickets divided by the total number of tickets that agent handled. An agent who handled no tickets has a resolution rate of `0`. Round the rate to two decimal places.
Return a DataFrame with `agent_id` and `resolution_rate` for every agent, in any order.
Input data
Example rows — the live problem includes the full dataset.
| agent_id | hired_at |
|---|---|
| 3 | 2020-03-21 10:16:13 |
| 7 | 2020-01-04 13:57:59 |
| 2 | 2020-07-29 23:09:44 |
| 6 | 2020-12-09 10:39:37 |
| agent_id | opened_at | outcome |
|---|---|---|
| 3 | 2021-01-06 03:30:46 | escalated |
| 3 | 2021-07-14 14:00:00 | escalated |
| 7 | 2021-06-12 11:57:29 | resolved |
| 7 | 2021-06-13 12:58:28 | resolved |
| 7 | 2021-06-14 13:59:27 | resolved |
Expected output
Your answer should return 4 rows with the columns agent_id, resolution_rate.
Starter code (Pandas (Python))
import pandas as pd
def agent_resolution_rate(agents: pd.DataFrame, tickets: pd.DataFrame) -> pd.DataFrame:
# Your code here
return agentsSolve 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