Same-Day Repair Rate by Logged Date
Problem
You are given a DataFrame `repair_ticket` with columns `ticket_id`, `device_id`, `logged_date`, and `fixed_date` (date strings). A ticket is a *same-day repair* when its `fixed_date` equals its `logged_date`.
For each distinct `logged_date`, compute the percentage of tickets logged that day that were same-day repairs. Round the percentage to 2 decimal places and name the column `same_day_rate`. Output `logged_date` and `same_day_rate`, ordered by `logged_date`.
Input data
Example rows — the live problem includes the full dataset.
| ticket_id | device_id | logged_date | fixed_date |
|---|---|---|---|
| 1 | 11 | 2024-03-01 | 2024-03-02 |
| 2 | 12 | 2024-03-01 | 2024-03-01 |
| 3 | 11 | 2024-03-01 | 2024-03-01 |
| 4 | 13 | 2024-03-02 | 2024-03-02 |
| 5 | 14 | 2024-03-02 | 2024-03-05 |
Expected output
Your answer should return 2 rows with the columns logged_date, same_day_rate.
Starter code (Pandas (Python))
import pandas as pd
def same_day_repair_rate_by_logged_date(repair_ticket) -> pd.DataFrame:
# Your code here
return repair_ticketSolve 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