Committed Gym Members
Problem
One CSV file, `member_visits.csv`, logs every gym member visit (`visit_id`, `member_id`, `visit_date`, `visit_kind`), where `visit_kind` is either 'checkin' (they showed up) or 'noshow' (a booked slot they missed). A member counts as committed when they meet all of: at least 3 check-ins, an active span of at least 30 days between their first and last logged visit, and a no-show rate below 20% (no-shows divided by all logged visits). Return the `member_id` of every committed member, ordered by `member_id` ascending.
Input data
Example rows — the live problem includes the full dataset.
| visit_id | member_id | visit_date | visit_kind |
|---|---|---|---|
| 1 | 201 | 2024-01-05 | checkin |
| 2 | 201 | 2024-01-20 | checkin |
| 3 | 201 | 2024-02-10 | checkin |
| 4 | 201 | 2024-02-15 | checkin |
| 5 | 202 | 2024-01-10 | checkin |
Expected output
Your answer should return 1 row with the columns member_id.
Starter code (Pandas (Python))
import pandas as pd
def find_committed_members(member_visits) -> pd.DataFrame:
# Your code here
return member_visitsSolve 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