AnalystPath

Same-Day Repair Rate by Logged Date

PandasMediumMid level~10 min

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.

repair_ticket
ticket_iddevice_idlogged_datefixed_date
1112024-03-012024-03-02
2122024-03-012024-03-01
3112024-03-012024-03-01
4132024-03-022024-03-02
5142024-03-022024-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_ticket

Solve 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

Related Pandas questions