Flag Menu Items Whose Price Jumped Over 20 Percent

Last updated: November 29, 2026

Quick Overview

Given daily menu price snapshots per store and item, write pandas code that compares each snapshot to the previous one for the same item and returns every change where the price rose by more than 20 percent.

DoorDash
Data Manipulation (SQL/Python)
Data Scientist
DoorDash
November 29, 2026
Data Scientist
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Given daily menu price snapshots per store and item, write pandas code that compares each snapshot to the previous one for the same item and returns every change where the price rose by more than 20 percent.

DoorDash monitors merchant menu prices for unusual markups versus in-store prices and for pricing errors that hurt conversion. This Python phone screen question checks groupby plus shift, sorting before comparing, and guarding against divide-by-zero and duplicate snapshots.

What the Interviewer Expects
  • Sort by store, item and snapshot date before shifting
  • Use groupby shift so comparisons never cross items
  • Deduplicate multiple snapshots on the same date
  • Skip rows with no previous price or a previous price of zero
  • Return both old and new price and the percent change
Key Topics to Cover
pandas
groupby shift
lag comparison
deduplication
data quality
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you flag only changes that stayed in place for at least 3 days, ignoring one-day glitches?
  • How would you summarize which stores raise prices most often?
  • How would you compare menu prices to in-store prices if you had a reference table?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

snap(store_id, item_id, snapshot_date, price), possibly unsorted, with occasional duplicate rows for the same date (keep the last). Compare with the previous available snapshot, which may be sever...

Approach

Drop duplicates on the key, sort, then groupby(['store_id','item_id']) and shift() to get the previous price and date on each row. Compute percent change, then filter to previous price greater tha...


Submit Your Answer
Markdown supported