Same-Day Rate on First Tickets
Problem
You are given a DataFrame `requests` loaded from `requests.csv` with columns `request_id`, `client_id`, `opened_on`, and `resolved_on`. Each row is one support request; a single client may file many requests.
Look only at each client's **first request** (their earliest `opened_on`). Among those first requests, compute the percentage that were resolved on the same day they were opened (`opened_on` equals `resolved_on`), rounded to 2 decimal places. Return a one-row, one-column DataFrame whose only column is `same_day_pct`. Assume each client has a single earliest request date.
Input data
Example rows — the live problem includes the full dataset.
| request_id | client_id | opened_on | resolved_on |
|---|---|---|---|
| 1 | 7 | 2024-01-01 | 2024-01-01 |
| 2 | 7 | 2024-02-01 | 2024-02-05 |
| 3 | 8 | 2024-01-10 | 2024-01-12 |
Expected output
Your answer should return 1 row with the columns same_day_pct.
Starter code (Pandas (Python))
import pandas as pd
def same_day_rate(requests) -> pd.DataFrame:
# Your code here
return requestsSolve 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