Took me a second to realize this was three-way join territory and not just two tables.
Start by clarifying the grain of each DataFrame and the join keys, then perform a left join from orders to products to categories to preserve all order lines. Compute the three metrics per category using groupby aggregations, ensuring that completion rate is calculated as the mean of a boolean indicator for status == 'completed'. Finally, validate the results and discuss any edge cases or assumptions.
Pro tip: Mention that you would check for duplicate product_id or category_id in the dimension tables before joining, as duplicates would inflate sales metrics. Also, consider whether to include only completed orders for sales metrics or all orders, and state your assumption clearly.
Examine the schema and grain of each DataFrame. Identify that orders is the fact table, products and categories are dimension tables, and the join keys are product_id and category_id. Decide on the join type (likely left join to keep all orders).
Join orders to products on product_id, then join the result to categories on category_id. Ensure the joins are correct and handle any missing matches appropriately.
Create a new column for sales (quantity * unit_price). Group by category_name (or category_id) and compute: total sales as sum of sales, average sales per order line as mean of sales, and completion rate as mean of (status == 'completed').
Check for anomalies, such as categories with zero orders or unexpected completion rates. Discuss any assumptions made (e.g., whether to include non-completed orders in sales metrics) and how they affect the results.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.