High-Balance Loyalty Members
Problem
You are given two DataFrames:
- `members` with `card`, `member_name`
- `pointevents` with `event_id`, `card`, `points`, `happened_on` (points may be positive for earning or negative for redeeming)
Each member's balance is the sum of all their point events. Return the members whose total balance is strictly greater than 10000.
Return columns `member_name` and `balance`. Members with no point events, or with a balance of 10000 or less, are excluded.
Input data
Example rows — the live problem includes the full dataset.
| card | member_name |
|---|---|
| 700001 | Priya |
| 700002 | Marco |
| 700003 | Lena |
| event_id | card | points | happened_on |
|---|---|---|---|
| 1 | 700001 | 7000 | 2021-08-01 |
| 2 | 700001 | 7000 | 2021-09-01 |
| 3 | 700001 | -3000 | 2021-09-02 |
| 4 | 700002 | 1000 | 2021-09-12 |
| 5 | 700003 | 6000 | 2021-08-07 |
Expected output
Your answer should return 1 row with the columns member_name, balance.
Starter code (Pandas (Python))
import pandas as pd
def high_balance_loyalty_members(members, pointevents) -> pd.DataFrame:
# Your code here
return membersSolve 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