Tags:

Introduction

Exploratory Data Analysis (EDA) is one of the most important stages of a Data Analytics project. Before building dashboards, developing machine learning models, or generating business reports, analysts need to understand the structure, quality, patterns, and relationships within a dataset.

In this practical exercise, we will perform Exploratory Data Analysis on a Retail Sales Dataset using Python, Pandas, Matplotlib, and Seaborn. The dataset contains 200 retail transactions and 13 columns, including store regions, product categories, payment methods, customer types, gross sales, discounts, and net sales.

We will begin by inspecting the dataset, checking missing values and duplicates, and calculating five important Key Performance Indicators (KPIs) using Pandas. After that, we will create six different visualisations using Seaborn to understand regional sales performance, product category contribution, payment preferences, customer spending patterns, discount impact, and transaction distribution.

Get the Dataset Here: https://slidescope.in/digital-store/retail-store-sales-dataset-for-ai-ml-and-data-analytics-2026/

The objective is not simply to create charts but to understand what each visualisation tells us about the business and how data can support better retail decisions.

1. Importing Libraries and Loading the Dataset

The first step in an EDA project is importing the required Python libraries.

We will use:

  • Pandas: For data loading, manipulation, grouping, and calculations.
  • Matplotlib: For creating and customising visualisations.
  • Seaborn: For statistical data visualisation.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

Now, let’s load the Retail Sales Dataset.

df = pd.read_csv("Slidescope_Retail_Store_Sales_Enhanced_2026(3).csv")

To understand the size and structure of our dataset, use:

print(df.shape)
print(df.head())
print(df.info())

The shape function returns the number of rows and columns, head() displays the first five records, and info() provides information about column names, data types, and non-null values.

Our dataset contains:

  • 200 rows (transactions)
  • 13 columns
  • 5 categorical columns
  • 8 numerical columns

2. Checking Missing Values and Duplicate Records

Data quality is an important part of Exploratory Data Analysis. Missing values and duplicate records can affect calculations and produce misleading analytical results.

We can identify missing values using:

print(df.isnull().sum())

To check duplicate records:

print(df.duplicated().sum())

The results show that our dataset contains zero missing values and zero duplicate rows.

This means we can proceed with the analysis without needing to perform missing-value treatment or duplicate removal.

3. Calculating Five Key Performance Indicators Using Pandas

Key Performance Indicators are measurable values that help businesses evaluate their performance.

For our Retail Sales Dataset, we will calculate five KPIs:

  1. Total Transactions
  2. Total Items Sold
  3. Gross Sales
  4. Total Discounts
  5. Net Sales

Instead of displaying these KPIs separately, we will create a Pandas DataFrame containing all five KPIs as columns.

kpi_df = pd.DataFrame([{
    "Total Transactions": df["Transaction_ID"].nunique(),
    "Total Items Sold": df["Items_Sold"].sum(),
    "Gross Sales": df["Gross_Amount"].sum(),
    "Total Discounts": df["Discount_Amount"].sum(),
    "Net Sales": df["Net_Sales_Amount"].sum()
}])

print(kpi_df.round(2))

Understanding the five KPIs:

Total Transactions: Counts the unique transaction IDs. It tells us how many individual transactions were recorded.

Total Items Sold: Calculates the sum of all quantities sold using the Items_Sold column.

Gross Sales: Calculates total sales before applying discounts.

Total Discounts: Measures the combined discount amount provided across all transactions.

Net Sales: Represents the actual sales amount after deducting discounts.

Our dataset produces the following results:

KPIValue
Total Transactions200
Total Items Sold1,977
Gross Sales1,038,118.63
Total Discounts145,866.52
Net Sales892,252.11

These five KPIs provide a quick overview of the retail business before we move towards deeper visual analysis.

4. Creating Six Visualisations Using Python Seaborn

Now that we understand the dataset and have calculated the KPIs, let’s create six visualisations to explore different aspects of retail sales.

Visualisation 1: Net Sales by Store Region

Chart Type: Bar Plot

A retail business operating across multiple regions needs to understand which geographical locations generate the highest revenue.

For this analysis, we will group the data by Store_Region and calculate the total net sales for each region.

region_sales = df.groupby(
    "Store_Region"
)["Net_Sales_Amount"].sum().reset_index()

plt.figure(figsize=(9, 5))

sns.barplot(
    data=region_sales,
    x="Store_Region",
    y="Net_Sales_Amount",
    hue="Store_Region",
    palette="deep",
    legend=False
)

plt.title("Net Sales by Store Region")
plt.xlabel("Store Region")
plt.ylabel("Net Sales")
plt.show()

Why are we creating this visualisation?

The purpose is to compare the sales contribution of different store regions. Management can identify high-performing and underperforming regions and investigate the reasons behind their performance.

Business Insight: North generates the highest net sales, while East generates the lowest. The business can investigate regional demand, product availability, and marketing performance to understand this difference.

Visualisation 2: Net Sales by Product Category

Chart Type: Bar Plot

A retail store generally sells multiple product categories. Understanding which categories generate the most revenue helps businesses make better inventory and purchasing decisions.

We will group the dataset using Product_Category and calculate the total net sales.

category_sales = df.groupby(
    "Product_Category"
)["Net_Sales_Amount"].sum().reset_index()

plt.figure(figsize=(9, 5))

sns.barplot(
    data=category_sales,
    x="Product_Category",
    y="Net_Sales_Amount",
    hue="Product_Category",
    palette="deep",
    legend=False
)

plt.title("Net Sales by Product Category")
plt.xlabel("Product Category")
plt.ylabel("Net Sales")
plt.xticks(rotation=20)
plt.show()

Why are we creating this visualisation?

This chart helps identify the product categories contributing the most to total revenue. Retail managers can use this information to plan inventory, allocate shelf space, and develop category-specific promotional strategies.

Business Insight: Apparel generates the highest net sales, followed by Furniture. Grocery and Electronics generate comparatively lower sales in this dataset.

Visualisation 3: Transactions by Payment Method

Chart Type: Count Plot

Customers can use different payment methods when purchasing products. These may include UPI, Cash, Credit Card, and Wallet.

Instead of calculating total revenue, we want to understand how frequently each payment method is used.

For this purpose, we will use Seaborn’s countplot() function.

plt.figure(figsize=(9, 5))

sns.countplot(
    data=df,
    x="Payment_Method",
    order=df["Payment_Method"].value_counts().index,
    hue="Payment_Method",
    palette="deep",
    legend=False
)

plt.title("Transactions by Payment Method")
plt.xlabel("Payment Method")
plt.ylabel("Transaction Count")
plt.show()

Why are we creating this visualisation?

This visualisation helps businesses understand customer payment preferences. It can support decisions related to payment infrastructure, checkout processes, and digital payment facilities.

Business Insight: UPI is the most frequently used payment method with 54 transactions, followed by Cash with 50 transactions. Wallet has the lowest transaction count with 47 transactions.

Visualisation 4: Net Sales Distribution by Customer Type

Chart Type: Box Plot

Our dataset contains four customer types:

  • New
  • Member
  • Guest
  • Returning

We want to understand whether different customer groups have different spending patterns.

A Box Plot is useful because it displays the median, quartiles, spread of values, and potential outliers.

plt.figure(figsize=(9, 5))

sns.boxplot(
    data=df,
    x="Customer_Type",
    y="Net_Sales_Amount",
    hue="Customer_Type",
    palette="deep",
    legend=False
)

plt.title("Net Sales Distribution by Customer Type")
plt.xlabel("Customer Type")
plt.ylabel("Net Sales per Transaction")
plt.show()

Why are we creating this visualisation?

A business should understand whether its members, returning customers, or new customers generate higher transaction values.

This chart helps compare customer spending behaviour and identify unusual high-value or low-value transactions.

Business Insight: Members have a higher median net sales value than the other customer groups. This may indicate that membership customers generate higher-value transactions. However, further analysis would be required to establish the reasons.

Visualisation 5: Gross Sales vs Net Sales

Chart Type: Scatter Plot

One of the most interesting aspects of retail sales analysis is understanding how discounts influence the final sales amount.

Our dataset contains both Gross_Amount and Net_Sales_Amount, along with Discount_Percent and Items_Sold.

We will use a Scatter Plot to examine the relationship between gross sales and net sales.

plt.figure(figsize=(9, 5))

sns.scatterplot(
    data=df,
    x="Gross_Amount",
    y="Net_Sales_Amount",
    hue="Discount_Percent",
    size="Items_Sold",
    sizes=(35, 180),
    palette="viridis",
    alpha=0.8
)

plt.title("Gross Sales vs Net Sales")
plt.xlabel("Gross Amount")
plt.ylabel("Net Sales Amount")
plt.show()

Understanding the chart:

  • X-axis: Gross Amount
  • Y-axis: Net Sales Amount
  • Bubble Colour: Discount Percentage
  • Bubble Size: Number of Items Sold

Why are we creating this visualisation?

We want to understand how gross sales relate to the final revenue received after discounts.

The scatter plot also helps identify whether transactions with higher discount percentages have a larger difference between gross and net sales.

Business Insight: There is a strong positive relationship between gross sales and net sales. Transactions with higher gross amounts generally have higher net sales, although discounts reduce the final amount received.

Visualisation 6: Distribution of Net Sales by Customer Type

Chart Type: Histogram

The final visualisation focuses on understanding the distribution of transaction values.

A Histogram divides numerical data into intervals called bins and displays how many observations fall within each interval.

We will use Net_Sales_Amount to understand the distribution of transaction values and use Customer_Type to differentiate the customer groups.

plt.figure(figsize=(9, 5))

sns.histplot(
    data=df,
    x="Net_Sales_Amount",
    hue="Customer_Type",
    bins=20,
    multiple="stack",
    palette="deep",
    kde=False
)

plt.title("Distribution of Net Sales by Customer Type")
plt.xlabel("Net Sales Amount")
plt.ylabel("Transaction Frequency")
plt.show()

Why are we creating this visualisation?

A business may have hundreds or thousands of transactions, but not all transactions generate the same amount of revenue.

This chart helps us understand whether most customers make smaller purchases or whether a significant number of transactions generate higher sales values.

Business Insight: Most transactions are concentrated in the lower net-sales ranges, while relatively few transactions generate very high sales values. This suggests that the dataset contains a larger number of smaller-value purchases compared with high-value transactions.

Conclusion

Exploratory Data Analysis is an essential part of the data analytics process because it helps analysts understand what is happening inside a dataset before developing reports, dashboards, or predictive models.

In this practical exercise, we analysed a Retail Sales Dataset containing 200 transactions and 13 columns using Python Pandas and Seaborn.

We started by inspecting the dataset, checking its dimensions, identifying data types, and verifying missing values and duplicate records. After confirming that the dataset contained no missing values or duplicate rows, we calculated five important business KPIs using Pandas.

We then created six visualisations to explore different aspects of retail business performance.

The regional sales analysis helped us compare revenue across four store regions. Product category analysis identified Apparel as the leading revenue contributor. Payment method analysis showed that UPI was the most frequently used payment method. The box plot helped compare transaction values across different customer types, while the scatter plot demonstrated the relationship between gross sales and net sales. Finally, the histogram helped us understand how transaction values were distributed across customer groups.

Each visualisation serves a different analytical purpose. Bar plots are useful for category comparisons, count plots measure frequency, box plots examine distributions and outliers, scatter plots explore relationships between numerical variables, and histograms help understand numerical data distributions.

The most important learning outcome is that EDA is not just about writing Python code or creating attractive charts. It is about asking meaningful business questions, selecting the right analytical techniques, and interpreting the results correctly.

By combining Pandas for data manipulation with Seaborn for visualisation, analysts can transform raw retail transaction data into meaningful business insights and make more informed decisions.

Disclaimer: The observations in this exercise are based on the supplied sample dataset of 200 transactions. They should not automatically be treated as representative of an entire retail business.