Gyms With Membership Growth in 2023
Problem
You are given a DataFrame `gymbranches` with columns `branch_id`, `season`, and `net_signups`. Each row records the net change in active members at a gym branch during a given season; `net_signups` can be negative when more members cancelled than joined.
Report the `branch_id` of every branch whose `net_signups` in season `2023` was **strictly greater than 0**.
Return a single column `branch_id` in any order.
Input data
Example rows — the live problem includes the full dataset.
| branch_id | season | net_signups |
|---|---|---|
| 1 | 2022 | 50 |
| 1 | 2023 | 120 |
| 2 | 2023 | -30 |
| 3 | 2023 | 0 |
| 4 | 2023 | 8 |
Expected output
Your answer should return 2 rows with the columns branch_id.
Starter code (Pandas (Python))
import pandas as pd
def gyms_with_membership_growth(gymbranches) -> pd.DataFrame:
# Your code here
return gymbranchesSolve 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