Daily Warranty Approval Rate
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.
| customer_id | device_id | event_day | event_type | channel |
|---|---|---|---|---|
| 1 | 101 | 2023-03-01 | claim | warranty |
| 2 | 102 | 2023-03-01 | claim | warranty |
| 3 | 103 | 2023-03-02 | claim | warranty |
| 4 | 104 | 2023-03-02 | inspect | warranty |
| device_id | paid_day |
|---|---|
| 101 | 2023-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 claimeventsSolve 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