Start by clarifying the data schema and assumptions (e.g., date granularity, missing dates, product coverage). Then outline a pandas pipeline: sort by product and date, compute rolling average per product, pivot to date-by-product matrix, and merge aggregated units sold per product. Finally, discuss edge cases like missing dates and how to handle them.
Pro tip: Mention that you would verify the rolling window is computed on a complete date range per product (reindexing to fill missing dates) to avoid incorrect averages, and that you'd use merge with how='left' to preserve all dates.
Confirm the table schema, date frequency, and whether each product has data for every date. Ask about handling missing dates and whether the rolling average should be computed on calendar days or available data points.
Sort by product_id and date, then use groupby('product_id')['revenue'].rolling(window=3, min_periods=1).mean() to compute the 3-day rolling average. Reset index to flatten the result.
Use pivot_table or pivot with index='date', columns='product_id', values='rolling_avg_revenue' to reshape the data so each row is a date and each column is a product.
Compute total units sold per product using groupby('product_id')['units_sold'].sum(), then merge this as a new row or column into the pivoted DataFrame, ensuring alignment with product columns.
Check for missing values, verify the rolling window logic, and discuss how to handle products with insufficient history. Mention potential performance considerations for large datasets.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.