AnalystPath

Same-Day Rate on First Tickets

PandasMediumMid level~10 min

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.

requests
request_idclient_idopened_onresolved_on
172024-01-012024-01-01
272024-02-012024-02-05
382024-01-102024-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 requests

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