AnalystPath

Always Mid-Pack Bakers

PandasHardSenior level~10 min

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.

bakers
baker_idbaker_name
1Hana
2Ravi
3Sora
4Tom
5Uma
round_scores
round_idbaker_idscore
10170
10280
10390
20180
30170

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 bakers

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