Coupon Redemption Rate
Problem
DataFrame: `couponsent` (`couponsent.csv`)
```text
+------------+--------+
| Column | Type |
+------------+--------+
| store_id | int |
| shopper_id | int |
| sent_on | object |
+------------+--------+
```
DataFrame: `couponredeemed` (`couponredeemed.csv`)
```text
+-------------+--------+
| Column | Type |
+-------------+--------+
| store_id | int |
| shopper_id | int |
| redeemed_on | object |
+-------------+--------+
```
A coupon is identified by the `(store_id, shopper_id)` pair. The same pair may appear more than once in either DataFrame.
Report the overall **redemption rate**: the number of distinct `(store_id, shopper_id)` pairs that were redeemed divided by the number of distinct `(store_id, shopper_id)` pairs that were sent, rounded to 2 decimal places. Return a single column named `redeem_rate`. If no coupons were ever sent, the rate is `0.00`.
Input data
Example rows — the live problem includes the full dataset.
| store_id | shopper_id | sent_on |
|---|---|---|
| 1 | 10 | 2023-03-01 |
| 1 | 11 | 2023-03-01 |
| 1 | 12 | 2023-03-01 |
| 2 | 10 | 2023-03-02 |
| 2 | 13 | 2023-03-09 |
| store_id | shopper_id | redeemed_on |
|---|---|---|
| 1 | 10 | 2023-03-03 |
| 1 | 11 | 2023-03-08 |
| 1 | 11 | 2023-03-08 |
| 2 | 13 | 2023-03-09 |
| 2 | 13 | 2023-03-10 |
Expected output
Your answer should return 1 row with the columns redeem_rate.
Starter code (Pandas (Python))
import pandas as pd
def redemption_rate(couponsent: pd.DataFrame, couponredeemed: pd.DataFrame) -> pd.DataFrame:
# Your code here
return couponsentSolve 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