This is my data science project where I analyzed supermarket sales data to understand sales patterns, profitability, and customer behavior.
I explored sales by category, region, time periods, discount impacts, and customer purchasing patterns to derive actionable business insights.
- Python 3.x
- Pandas - Data manipulation and analysis
- NumPy - Numerical operations
- Matplotlib & Seaborn - Data visualization and statistical plotting
- File: supermarket_sales.csv
- Records: Multiple transactions from a supermarket chain
- Key Features: Order Date, Category, Sub Category, City, Region, State, Sales, Profit, Discount, Customer Name
This dataset had dates in multiple formats (DD-MM-YYYY, DD/MM/YYYY, M/D/YYYY).
I used pd.to_datetime with format='mixed' and dayfirst=True to handle this challenge.
What I understood: Real-world data is messy. Dates come in various formats and I need robust methods to parse them correctly.
My learning: Always check date formats and use flexible parsing methods. One wrong date format can break the entire analysis.
I extracted useful features from the Order Date: Month, Year, Day, Day_of_Week, and Quarter.
This completely transformed my analysis capabilities.
What I understood: Date columns are gold mines of information. Converting them into structured features (like month or quarter) enables trend analysis and seasonality detection.
My learning: Don't leave dates as raw strings. Extract meaningful components for better analysis.
I created new calculated columns:
- Profit_Margin: (Profit/Sales) * 100 - Shows profitability percentage
- Discount_Amount: Sales * Discount - Actual discount value
- Net_Sales: Sales - Discount_Amount - Revenue after discounts
What I understood: Raw data often needs transformation to answer real business questions. The right calculated fields make insights obvious.
My learning: Always think from a business perspective - what metrics would a manager or executive want to see?
I analyzed sales across multiple dimensions:
- By Category and Sub-Category (Product perspective)
- By Region, State, and City (Geographic perspective)
- By Month, Quarter, and Day of Week (Time perspective)
What I understood: One-dimensional analysis (like just total sales) tells a limited story. Combining dimensions reveals rich patterns.
My learning: Always ask "What other dimension could add context to this analysis?"
The scatter plot of Sales vs Profit showed me that higher sales don't always mean higher profit.
Some products with high sales might have low profit margins.
What I understood: Revenue is vanity, profit is sanity. A business should focus on profitability, not just sales volume.
My learning: Always analyze both top-line (sales) and bottom-line (profit) metrics together.
I analyzed discount distribution, average discount by category, and the relationship between discounts and sales.
What I understood: Discounts can drive sales but might erode profits. I found that certain categories had higher discounts than others, which might indicate strategic pricing or inventory clearance.
My learning: Discounts are a double-edged sword. Data helps find the right balance between driving sales and maintaining profitability.
I analyzed sales by Region, State, and City to identify high-performing and underperforming areas.
What I understood: Geographic performance varies significantly. Some regions consistently outperform others. This could guide marketing spend, inventory allocation, or store expansion decisions.
My learning: Geographic analysis is critical for businesses with multi-location operations. It helps in resource allocation and targeted strategies.
Monthly and quarterly sales trends showed clear patterns in business performance.
Some months/quarters performed significantly better than others.
What I understood: Businesses aren't static - they have seasonal patterns. Understanding these patterns helps in planning inventory, staffing, and promotions.
My learning: Time-based analysis reveals patterns that static analysis misses. Always look at trends over time.
I analyzed top customers and order frequency distribution.
The analysis showed that a small number of customers contribute a large portion of revenue.
What I understood: The Pareto Principle (80/20 rule) applies here - a small percentage of customers drive most of the sales. This has implications for customer relationship management.
My learning: Customer segmentation is crucial. Identify your VIP customers and provide them with special attention.
I created a correlation matrix to understand relationships between numerical variables.
Sales and Profit had a moderate correlation, while Discount and Profit had a negative correlation.
What I understood: Correlations help identify which metrics move together and which move in opposite directions. This guides business decisions - for example, understanding that discounting negatively impacts profit.
My learning: Correlation analysis is a powerful tool for understanding business dynamics. Always include it in your analysis.
I used heatmaps for Category vs Region sales and correlation matrices.
Heatmaps made it easy to spot patterns at a glance.
What I understood: Heatmaps are excellent for displaying matrix data. They use color intensity to represent values, making patterns immediately visible.
My learning: Choose visualization types based on the data structure. Heatmaps work best for matrix-like data.
I limited visualizations to top 10 or top 15 sub-categories to avoid clutter.
I also filtered data to show only the most relevant items.
What I understood: Not all categories need to be shown. Showing only the top performers makes visualizations cleaner and more insightful.
My learning: When you have many categories, summarize or filter. Focus on what matters most.
I created a heatmap showing Category sales by Region and stacked bar charts showing sub-category distribution by Region.
What I understood: Different regions have different product preferences. A product that sells well in one region might not perform in another.
My learning: Regional product preferences exist. Use data to tailor inventory to local demand.
While this dataset had no missing values, I practiced checking for them systematically.
What I understood: Always verify data quality before analysis. Trust but verify.
My learning: Data cleaning should be a standard first step in every project, not an afterthought.
The executive summary at the end pulled everything together - total revenue, profit, top categories, regional performance, and key insights.
What I understood: Analysis is only valuable if it can be communicated effectively. A good summary tells a complete story.
My learning: Always end with a clear, concise summary. Make it easy for decision-makers to act on your insights.
| What I Found | My Understanding |
|---|---|
| Total Revenue | Overall business performance metric |
| Total Profit | Bottom-line business health |
| Category Performance | Which product categories drive revenue and profit |
| Regional Performance | Geographic variations in sales and profit |
| Top Sub-Categories | Focus on most profitable product segments |
| Monthly/Quarterly Trends | Seasonal patterns in business performance |
| Sales vs Profit Relationship | High sales doesn't guarantee high profit |
| Discount Impact | Discounts can drive sales but may reduce profit |
| Customer Concentration | Few customers contribute most revenue (80/20 rule) |
| Correlation Insights | Discount negatively impacts profit |
- Predictive modeling - Forecast future sales based on historical patterns
- Customer segmentation - Cluster customers by purchasing behavior
- Inventory optimization - Identify which products to stock more
- Pricing strategy analysis - Find optimal price points for categories
- Market basket analysis - Which products are often bought together
- Anomaly detection - Identify unusual sales patterns or outliers
- Store-level analysis - Compare performance across individual stores
- Promotion effectiveness - Measure ROI of marketing campaigns
- I can now handle complex date formats in pandas
- I understand how to extract time-based features
- I can create business-relevant calculated columns
- I'm comfortable with various visualization types (bar, line, scatter, heatmap, pie)
- I can filter and limit data for cleaner visualizations
- I learned to analyze data from multiple dimensions (product, region, time)
- I understand the difference between revenue and profit
- I can identify seasonal patterns in business data
- I recognize the importance of customer segmentation
- I can derive actionable business insights from raw data
- I can think from a business perspective
- I understand how data drives business decisions
- I can present findings in a structured executive summary
- I know how to ask the right business questions
- I can translate data patterns into business recommendations
-
Date Format Handling - The dataset had mixed date formats that I successfully parsed using format='mixed' and dayfirst=True
-
Feature Extraction - I learned to extract meaningful components from dates (month, quarter, day of week)
-
Visualization Clutter - I limited visualizations to top performers to maintain clarity
-
Business Metric Creation - I created profit margin, discount amount, and net sales from raw data
-
Multi-Dimensional Analysis - I combined multiple dimensions in single visualizations using pivot tables and heatmaps
Step 1: Install required libraries
pip install pandas numpy matplotlib seabornStep 2: Ensure 'supermarket_sales.csv' is in the same directory
Step 3: Run the analysis script
python supermarket_analysis.py├── supermarket_sales.csv # Dataset
├── supermarket_analysis.py # Main analysis script
└── README.md # Project documentation
This project taught me how to analyze business data from multiple angles and derive actionable insights. I started with raw transaction data and ended with a comprehensive understanding of sales patterns, profitability, regional performance, and customer behavior.
The biggest lesson: Data science in business is about driving decisions. Every analysis should answer a business question and provide actionable recommendations. It's not just about creating charts - it's about helping businesses make better decisions.
I also learned that real-world data is messy and requires careful cleaning and feature engineering. The date handling exercise alone taught me the importance of understanding data formats before analysis.
This project has prepared me to tackle more complex business analytics challenges and I'm excited to apply these skills to new problems.
This README documents my learning journey from working on the Supermarket Sales Analysis project. Written with reflection on both technical and analytical growth.