AnalystPath

Daily Warranty Approval Rate

PandasMediumMid level~10 min

Problem

DataFrame: `claimevents` (`claimevents.csv`)

```text
+-------------+--------+
| Column | Type |
+-------------+--------+
| customer_id | int |
| device_id | int |
| event_day | object |
| event_type | object |
| channel | object |
+-------------+--------+
```
Each row records an action on a device. `event_type` is `'claim'` or `'inspect'`. `channel` is `'warranty'` or `'retail'`.

DataFrame: `refunds` (`refunds.csv`)

```text
+-----------+--------+
| Column | Type |
+-----------+--------+
| device_id | int |
| paid_day | object |
+-----------+--------+
```
`device_id` is unique. A row means that device's warranty claim ended in a refund.

For each day, look only at warranty **claim** events. Compute what percentage of the devices claimed that day were eventually refunded. Then report the **average of those daily percentages** across all days, rounded to 2 decimal places. Name the single output column `avg_daily_pct`.

Input data

Example rows — the live problem includes the full dataset.

claimevents
customer_iddevice_idevent_dayevent_typechannel
11012023-03-01claimwarranty
21022023-03-01claimwarranty
31032023-03-02claimwarranty
41042023-03-02inspectwarranty
refunds
device_idpaid_day
1012023-03-05

Expected output

Your answer should return 1 row with the columns avg_daily_pct.

Starter code (Pandas (Python))

import pandas as pd

def avg_daily_approval(claimevents: pd.DataFrame, refunds: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return claimevents

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