Middle-Tier Workshop Topics
Problem
Two DataFrames describe sign-ups for workshop topics.
`attendee` (`attendee.csv`) has columns `person_id`, `fullname`, `topic` — one row per person, recording which workshop `topic` they signed up for.
`topic` (`topic.csv`) has columns `topic_id`, `topic` — the catalogue of topics.
Find the workshop topics that are **neither the least popular nor the most popular**: every topic whose sign-up count is **strictly greater than the smallest** topic's count **and strictly less than the largest** topic's count. Return a DataFrame with the single column `topic`. Rows may be in any order.
**Example**
If `Welding` has 3 sign-ups (most), `Origami` has 1 (fewest), and `Pottery` has 2 (strictly between), only `Pottery` is returned.
Input data
Example rows — the live problem includes the full dataset.
| person_id | fullname | topic |
|---|---|---|
| 1 | Ada | Welding |
| 2 | Bo | Welding |
| 3 | Cy | Welding |
| 4 | Di | Pottery |
| 5 | Ed | Pottery |
| topic_id | topic |
|---|---|
| 1 | Welding |
| 2 | Pottery |
| 3 | Origami |
Expected output
Your answer should return 1 row with the columns topic.
Starter code (Pandas (Python))
import pandas as pd
def middle_tier_topics(attendee: pd.DataFrame, topic: pd.DataFrame) -> pd.DataFrame:
# Your code here
return attendeeSolve 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