Remove Day-of-Week Seasonality From Daily Marketplace Listings in Pandas
Last updated: November 29, 2026
Quick Overview
Daily new Facebook Marketplace listings spike on weekends. Using pandas, estimate a multiplicative day-of-week index from several weeks of history and produce a seasonally adjusted daily series that shows the underlying trend.
Meta
November 29, 20260
0
0 solved
Daily new Facebook Marketplace listings spike on weekends. Using pandas, estimate a multiplicative day-of-week index from several weeks of history and produce a seasonally adjusted daily series that shows the underlying trend.
A pandas take-home style question for Marketplace data scientists, where weekly cycles hide real trends in listing supply. The interviewer checks a centered moving average to isolate the trend, ratio-to-trend averaging by weekday, and normalization of the index.
What the Interviewer Expects
- Use a centered 7-day mean as the trend estimate
- Compute each day's ratio to trend
- Average ratios by weekday over full weeks
- Normalize the index to average 1
- Divide raw values by the index to adjust
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
- Why multiplicative rather than additive seasonality here?
- How would holidays distort the index and how would you handle them?
- How would you let the index drift slowly over time?
- How does STL decomposition compare?
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
daily is a pandas Series of listing counts on a complete DatetimeIndex with no gaps, starting on a Monday. I train the index on the first 8 full weeks and apply it to the whole series. Seasonality i...
Approach
The centered 7-day rolling mean averages one of each weekday, so it removes the weekly cycle and leaves the trend. Each day's ratio to that trend isolates its weekday effect. Averaging ratios per week...