Member Count per Club
Problem
You are given two DataFrames.
`club`
```text
+-----------+-----------+
| Column | Type |
+-----------+-----------+
| club_id | int |
| club_name | object |
+-----------+-----------+
club_id is the unique key.
```
`member`
```text
+-------------+-----------+
| Column | Type |
+-------------+-----------+
| member_id | int |
| member_name | object |
| year_level | object |
| club_id | int |
+-------------+-----------+
```
Count how many members belong to each club, including clubs with **zero** members. Return columns `club_name`, `member_count`, ordered by `member_count` descending, breaking ties by `club_name` ascending.
Input data
Example rows — the live problem includes the full dataset.
| member_id | member_name | year_level | club_id |
|---|---|---|---|
| 10 | Aya | Y1 | 1 |
| 11 | Ben | Y2 | 1 |
| 12 | Cole | Y1 | 2 |
| club_id | club_name |
|---|---|
| 1 | Chess |
| 2 | Robotics |
| 3 | Debate |
Expected output
Your answer should return 3 rows with the columns club_name, member_count.
Starter code (Pandas (Python))
import pandas as pd
def members_per_club(member: pd.DataFrame, club: pd.DataFrame) -> pd.DataFrame:
# Your code here
return memberSolve 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