Analyzing and Visualizing Sales Data
1. Introduction
The goal of this project is to analyze monthly sales data for three product categories
- Electronics, Clothing, and Home Appliances. The analysis identifies trends,
evaluates category performance, and visualizes insights to assist in decision-
making.
2. Tools and Libraries
Python: Programming language used for data analysis.
Pandas: Data manipulation and aggregation.
NumPy: Generation of random data for simulations.
Matplotlib: Visualization of sales data.
3. Data Description
A synthetic dataset was created to simulate monthly sales data. The dataset
includes:
Month: Time period (January to December).
Electronics, Clothing, Home Appliances: Sales figures (randomized values
in the range of 300-1000).
Total_Sales: Aggregated monthly sales across all categories.
4. Analysis Performed
4.1. Summary Statistics
Basic statistics were calculated, including mean, minimum, and maximum sales for
each category, and total monthly sales calculated by summing all categories.
4.2. Key Observations
- Each category displayed varied sales performance over the year.
- Monthly total sales showed fluctuations, indicating seasonal trends.
5. Visualizations
5.1. Monthly Sales Trends
A line chart shows the sales trends for each category across the year, highlighting
seasonal peaks and troughs, and comparisons between categories.
5.2. Total Monthly Sales
A bar chart visualizes the total sales per month, identifying high and low revenue
months.
5.3. Category-Wise Contribution
A pie chart illustrates the proportion of total annual sales contributed by each
category, providing insights into dominant product categories.
6. Insights
1. Electronics consistently outperformed other categories, contributing significantly
to total sales.
2. Sales in Clothing showed high variability, likely affected by seasonal demand.
3. Home Appliances had steady sales with fewer extreme fluctuations.
4. Monthly sales peaked during certain months (e.g., holidays), providing an
opportunity to optimize marketing and inventory.
7. Conclusion
This project demonstrates how data analysis and visualization can provide
actionable insights into business performance. By understanding category-wise
performance and sales trends, businesses can make data-driven decisions to
improve profitability.
Program :
# Import Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Create Sample Dataset
data = {
'Month': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov',
'Dec'],
'Electronics': np.random.randint(500, 1000, 12),
'Clothing': np.random.randint(300, 800, 12),
'Home_Appliances': np.random.randint(400, 900, 12),
}
sales_df = pd.DataFrame(data)
# Perform Basic Analysis
sales_df['Total_Sales'] = sales_df[['Electronics', 'Clothing',
'Home_Appliances']].sum(axis=1)
print("Summary Statistics:")
print(sales_df.describe())
print("\nDataset with Total Sales:")
print(sales_df)
# Line Plot for Trends
plt.figure(figsize=(10, 6))
for category in ['Electronics', 'Clothing', 'Home_Appliances']:
plt.plot(sales_df['Month'], sales_df[category], label=category)
plt.title('Monthly Sales Trends')
plt.xlabel('Month')
plt.ylabel('Sales')
plt.legend()
plt.grid()
plt.show()
# Bar Plot for Total Sales
sales_df.set_index('Month')['Total_Sales'].plot(kind='bar', color='skyblue',
figsize=(10, 6))
plt.title('Total Monthly Sales')
plt.xlabel('Month')
plt.ylabel('Total Sales')
plt.show()
# Pie Chart for Category-Wise Contribution
total_sales_by_category = sales_df[['Electronics', 'Clothing',
'Home_Appliances']].sum()
total_sales_by_category.plot(kind='pie', autopct='%1.1f%%', figsize=(8, 8),
startangle=140)
plt.title('Category-Wise Sales Contribution')
plt.ylabel('') # To remove the y-axis label
plt.show()
output: