Members Who Qualify for Loyalty Points
Problem
You are given one DataFrame `renewals` with columns `member_id`, `renewed_at`, and `fee_cents`. The pair `(member_id, renewed_at)` is unique.
A member qualifies for loyalty points if they made at least one renewal during the inclusive window from `'2023-09-01'` to `'2023-09-30'` that cost at least 5000 cents.
Return a single column `qualifying_members`: the number of distinct members who qualify.
Input data
Example rows — the live problem includes the full dataset.
| member_id | renewed_at | fee_cents |
|---|---|---|
| 1 | 2023-09-04 10:00:00 | 5200 |
| 1 | 2023-09-18 11:00:00 | 5200 |
| 2 | 2023-09-10 09:00:00 | 4000 |
| 3 | 2023-08-30 12:00:00 | 9000 |
| 4 | 2023-09-29 23:00:00 | 5000 |
Expected output
Your answer should return 1 row with the columns qualifying_members.
Starter code (Pandas (Python))
import pandas as pd
def qualifying_member_count(renewals) -> pd.DataFrame:
# Your code here
return renewalsSolve 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