Compute and Rank Store Revenue by Region Using Pandas
Company: Apple
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Onsite
Sales
+------------+---------+------------+--------+---------+
| date | store_id| product_id | units | revenue |
+------------+---------+------------+--------+---------+
|2023-01-01 |1 |101 |3 |30.00 |
|2023-01-01 |1 |102 |2 |40.00 |
|2023-01-02 |2 |101 |5 |50.00 |
|2023-01-02 |2 |103 |1 |20.00 |
|2023-01-02 |3 |101 |4 |40.00 |
+------------+---------+------------+--------+---------+
Stores
+---------+---------+
| store_id| region |
+---------+---------+
|1 | West |
|2 | East |
|3 | Central |
+---------+---------+
##### Scenario
Pandas data-wrangling coding task on sales data
##### Question
Using pandas, compute total revenue per store per day from the sales table. Merge the sales table with the stores table on store_id, then list the top three regions by total revenue.
##### Hints
Use groupby, agg, merge, sort_values, and reset_index appropriately.
Quick Answer: This question evaluates proficiency in pandas-based data manipulation, specifically competencies in aggregating revenue, merging store metadata, and producing ranked regional summaries.