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
November 29, 20260
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
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- 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 ProblemsSample 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...