groupby() basics
📖 Scenario: You work in a small store and have a list of sales records. Each record shows the product sold and the quantity sold. You want to find out how many items of each product were sold in total.
🎯 Goal: Use the groupby() function from pandas to group sales by product and calculate the total quantity sold for each product.
📋 What You'll Learn
Create a pandas DataFrame with sales data
Create a variable for grouping the data by product
Use
groupby() and sum() to calculate total quantitiesPrint the grouped result showing total quantity per product
💡 Why This Matters
🌍 Real World
Stores and businesses often need to summarize sales data by product to understand what sells best.
💼 Career
Data analysts and scientists use grouping and aggregation to prepare reports and find insights from data.
Progress0 / 4 steps