Busiest Reading Circles
Problem
DataFrame: `circle_membership` (`circle_membership.csv`)
```text
+-----------+------+
| Column | Type |
+-----------+------+
| circle_id | int |
| member_id | int |
+-----------+------+
Each row says a member belongs to a reading circle. (circle_id, member_id) is unique.
```
DataFrame: `reader` (`reader.csv`)
```text
+------------+--------+
| Column | Type |
+------------+--------+
| member_id | int |
| full_name | object |
| books_read | int |
+------------+--------+
member_id uniquely identifies each reader.
```
Write a function that returns the `circle_id` of every circle that has the **most** members. If several circles tie for the largest membership, return all of them. The `reader` table is not needed for the answer.
Return the rows in any order.
**Example**
Input — `circle_membership`:
```text
circle_id member_id
10 1
10 2
10 3
20 1
20 4
```
Output:
```text
circle_id
10
```
Circle 10 has 3 members and circle 20 has 2, so only circle 10 is returned.
Input data
Example rows — the live problem includes the full dataset.
| circle_id | member_id |
|---|---|
| 10 | 1 |
| 10 | 2 |
| 10 | 3 |
| 20 | 1 |
| 20 | 4 |
| member_id | full_name | books_read |
|---|---|---|
| 1 | Mara | 12 |
| 2 | Theo | 5 |
| 3 | Lin | 8 |
| 4 | Owen | 3 |
Expected output
Your answer should return 1 row with the columns circle_id.
Starter code (Pandas (Python))
import pandas as pd
def busiest_circles(circle_membership: pd.DataFrame, reader: pd.DataFrame) -> pd.DataFrame:
# Your code here
return circle_membershipSolve 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