AnalystPath

Busiest Reading Circles

PandasEasyJunior level~10 min

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_membership
circle_idmember_id
101
102
103
201
204
reader
member_idfull_namebooks_read
1Mara12
2Theo5
3Lin8
4Owen3

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_membership

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