Single and Multiple Column Grouping
📖 Scenario: You work in a small bookstore. You have sales data for different books, including the genre and the month when the book was sold. You want to understand how many books were sold by genre and by month.
🎯 Goal: Build a program that groups sales data by one column (genre) and then by two columns (genre and month) to count the number of books sold in each group.
📋 What You'll Learn
Create a dictionary with sales data including book titles, genres, and months sold
Create a pandas DataFrame from the dictionary
Group the data by the 'Genre' column and count the number of books sold per genre
Group the data by both 'Genre' and 'Month' columns and count the number of books sold per group
Print the results of both groupings
💡 Why This Matters
🌍 Real World
Grouping data by one or more columns is common in sales analysis, customer segmentation, and many other business tasks to summarize and understand data.
💼 Career
Data analysts and data scientists often use grouping to prepare data for reports and insights that help businesses make decisions.
Progress0 / 4 steps