AnalystPath

Top-Day Revenue Gap Between Two Branches

PandasEasyJunior level~10 min

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
branchsale_daterevenue
Riverside2024-04-011200
Riverside2024-04-023100
Riverside2024-04-032500
Hilltop2024-04-01900
Hilltop2024-04-024800

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_sales

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