Top-Day Revenue Gap Between Two Branches
Problem
DataFrame `daily_sales` has columns `branch`, `sale_date`, and `revenue`, with one row per branch per day. For the two branches `Riverside` and `Hilltop`, find each branch's single best day (its maximum `revenue`), then report the absolute difference between those two peak figures.
Return one row with the column `revenue_gap`.
Input data
Example rows — the live problem includes the full dataset.
daily_sales
| branch | sale_date | revenue |
|---|---|---|
| Riverside | 2024-04-01 | 1200 |
| Riverside | 2024-04-02 | 3100 |
| Riverside | 2024-04-03 | 2500 |
| Hilltop | 2024-04-01 | 900 |
| Hilltop | 2024-04-02 | 4800 |
Expected output
Your answer should return 1 row with the columns revenue_gap.
Starter code (Pandas (Python))
import pandas as pd
def top_day_revenue_gap(daily_sales) -> pd.DataFrame:
# Your code here
return daily_salesSolve 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