Top Bakery Showdown
Problem
Two bakeries compete on five-star reviews. You are given two DataFrames, `sunrise_bakery` and `harbor_bakery`, each loaded from a CSV with columns `(review_id, stars)` where `stars` runs from 1 to 5.
The `champion` is the bakery with MORE five-star reviews (`stars == 5`). Return a single-column DataFrame `champion` with:
- `'Sunrise Bakery'` if Sunrise has strictly more five-star reviews,
- `'Harbor Bakery'` if Harbor has strictly more,
- `'Tie'` if both have the same count.
Input data
Example rows — the live problem includes the full dataset.
| review_id | stars |
|---|---|
| 1 | 5 |
| 2 | 5 |
| 3 | 4 |
| 4 | 5 |
| review_id | stars |
|---|---|
| 1 | 5 |
| 2 | 3 |
| 3 | 5 |
Expected output
Your answer should return 1 row with the columns champion.
Starter code (Pandas (Python))
import pandas as pd
def top_bakery_showdown(sunrise_bakery, harbor_bakery) -> pd.DataFrame:
# Your code here
return sunrise_bakerySolve 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