Always Mid-Pack Bakers
Problem
A baking competition runs several rounds. In each round the judges give every competing baker a score. A baker is **mid-pack** if they entered at least one round and, in every round they entered, they were never the highest scorer nor the lowest scorer of that round.
DataFrame `bakers` (from `bakers.csv`):
| Column | Type |
|------------|---------|
| baker_id | int |
| baker_name | object |
DataFrame `round_scores` (from `round_scores.csv`): each row is one baker's score in one round, with columns `round_id`, `baker_id`, `score`.
Return a DataFrame with columns `baker_id` and `baker_name` for every mid-pack baker. A baker who never competed is not mid-pack. Sort the result by `baker_id`.
Input data
Example rows — the live problem includes the full dataset.
| baker_id | baker_name |
|---|---|
| 1 | Hana |
| 2 | Ravi |
| 3 | Sora |
| 4 | Tom |
| 5 | Uma |
| round_id | baker_id | score |
|---|---|---|
| 10 | 1 | 70 |
| 10 | 2 | 80 |
| 10 | 3 | 90 |
| 20 | 1 | 80 |
| 30 | 1 | 70 |
Expected output
Your answer should return 1 row with the columns baker_id, baker_name.
Starter code (Pandas (Python))
import pandas as pd
def find_mid_pack_bakers(bakers, round_scores) -> pd.DataFrame:
# Your code here
return bakersSolve 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