Last updated
Find the total revenue generated by each product category using Python and Pandas.
Find the total revenue generated by each product category using Python and Pandas.
Your dataset contains a sales_data DataFrame with order-level retail sales information, including product category, quantity, unit price, and order date.
| Column | Type | Key / Notes |
|---|---|---|
| order_id | INT | Unique order ID |
| product_category | VARCHAR(50) | Product category name |
| quantity | INT | Number of units sold |
| unit_price | FLOAT | Price per unit |
| order_date | DATE | Date of order |
sales_data — 8 rows
| order_id | product_category | quantity | unit_price | order_date |
|---|---|---|---|---|
| 101 | Electronics | 2 | 15000 | 2023-07-01 |
| 102 | Clothing | 5 | 1200 | 2023-07-02 |
| 103 | Electronics | 1 | 25000 | 2023-07-03 |
| 104 | Grocery | 10 | 300 | 2023-07-04 |
| 105 | Clothing | 3 | 1500 | 2023-07-05 |
| 106 | Grocery | 8 | 250 | 2023-07-06 |
| 107 | Furniture | 1 | 18000 | 2023-07-07 |
| 108 | Electronics | 3 | 10000 | 2023-07-08 |
Revenue Analysis: What is the total revenue generated by each product category? Your result table should have product_category and total_revenue columns.
Your output should look like this (partial example):
| product_category | total_revenue |
|---|---|
| Electronics | 85000 |
| Furniture | 18000 |
| ... | ... |