AnalystPath

Committed Gym Members

PandasMediumMid level~10 min

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.

member_visits
visit_idmember_idvisit_datevisit_kind
12012024-01-05checkin
22012024-01-20checkin
32012024-02-10checkin
42012024-02-15checkin
52022024-01-10checkin

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_visits

Solve 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

Related Pandas questions