← Boston Consulting Group Interview Insights
I got the left merge and fillna parts pretty quickly but fumbled on the mode imputation.
Start by clarifying the table structures and the desired output, then outline a step-by-step pandas workflow: merge with how='left', fill nulls appropriately, compute total_spent, and sort. Emphasize data integrity and edge cases like duplicate customers or missing modes.
Pro tip: Always validate the merge cardinality (e.g., check for duplicate customer IDs) and consider whether filling missing countries with the mode is the best business decision—sometimes a separate 'Unknown' category is more informative.
Clarify the schema of customers and orders tables, the join key, and confirm that all customers should be kept. Identify columns with missing values and the expected output format.
Use pd.merge(customers, orders, on='customer_id', how='left') to retain all customers. Check for duplicate customer IDs in orders and decide on aggregation if needed.
Replace null order amounts with 0 using fillna(0) before computing total_spent. For missing country values, compute the mode of the country column and fill nulls with that mode.
Create a new column total_spent as the sum of order amounts per customer (if multiple orders, group by customer first). Then sort the DataFrame by total_spent in descending order.
Check that no nulls remain in critical columns, verify the sorting, and ensure the output has the expected number of rows. Return the final DataFrame.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.