Flag Week-over-Week Save Rate Drops for Creators in Pandas
Last updated: November 29, 2026
Quick Overview
Given a pandas DataFrame of daily creator metrics (creator_id, date, impressions, saves), roll it up to Monday-start weeks and return creator-weeks where the save rate fell more than 30% relative to the immediately preceding week, ignoring weeks with too few impressions.
0
0
0 solved
Given a pandas DataFrame of daily creator metrics (creator_id, date, impressions, saves), roll it up to Monday-start weeks and return creator-weeks where the save rate fell more than 30% relative to the immediately preceding week, ignoring weeks with too few impressions.
Pinterest's creator tools surface analytics and alerts, and data scientists prototype alert logic in pandas before it becomes a pipeline. The interviewer checks clean groupby and shift usage, ratio-of-sums rather than mean-of-ratios, guards against noisy small denominators, and handling of missing weeks.
What the Interviewer Expects
- Aggregates to weeks with a ratio of sums, not an average of daily rates
- Uses groupby shift so comparisons never cross creators
- Requires the previous row to be exactly the previous week
- Applies a minimum-impressions guard on both weeks
- Returns a tidy, explainable output with before and after rates
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 replace the fixed 30% threshold with a statistical test on the two proportions?
- How would you adjust for platform-wide seasonality like the holiday spike?
- How would you scale this to every creator daily in Spark?
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
- One row per creator per day, but days with no activity may be missing entirely.
- Week starts Monday; to_period('W-SUN') gives weeks ending Sunday, whose start_time is Monday.
- Save rate = sum(save...
Approach
Convert dates, assign each row to its week, aggregate per creator-week, and sort. Within each creator, shift to get the previous week's rate, impressions and week start. Keep rows where the previous w...