Sunday, December 21, 2025

EDA in Public (Half 2): Product Deep Dive & Time-Collection Evaluation in Pandas


! Welcome again to the “EDA in Public” collection! That is Half 2 of the collection; in the event you haven’t seen Half 1 but, learn it right here. Right here’s a recap of what we conquered.

In Half 1, we took a messy, half-million-row gross sales file and obtained it into form. Particularly, we:

  • Sampled the info for sooner processing.
  • Fastened lacking values and standardised textual content entries (like ‘EIRE’ to ‘Eire’).
  • Filtered out all of the noise — returns, cancellations, and transactions with zero worth.
  • Engineered our most crucial function: the Income column.
  • Achieved our first enterprise perception: the High 10 Income-Producing International locations.

We now have a clear, revenue-ready Pandas DataFrame able to be exploited for insights! By the tip of this collection, I wish to have mastered exploratory information evaluation utilizing Pandas. Be at liberty to observe alongside in the event you’re an information fanatic.

Now we shift our focus to delivering actually impactful enterprise intelligence for NovaShop. Our total aim for Half 2 is to reply the elemental questions: What merchandise are the perfect performers, and when is the perfect time to promote them?

This half is all about evaluation utilizing highly effective Pandas aggregation methods (.groupby()) and have engineering utilizing the datetime column (.dt accessor). We’ll break down our evaluation into two key areas:

  • Product Deep Dive: Figuring out the merchandise that transfer probably the most models versus those who herald probably the most money.
  • Gross sales Timing (Time-Collection): Uncovering the seasonality of gross sales (month-to-month peaks) and the operational traits (busiest hour of the day).

With out additional ado, let’s get to it.

Loading the clear information

To enhance efficiency, let’s export our cleaned dataset and import it once more for evaluation

df.to_csv('online_retail_clean.csv', index=False)

Now, I can create a brand new undertaking and begin afresh.

When loading CSVs that comprise date columns, I attempt to use the parse_dates argument in pd.read_csv(). This protects me the step of manually changing the column kind later, guaranteeing the date options are right from the beginning.

import pandas as pd
df = pd.read_csv('online_retail_clean.csv', parse_dates=['InvoiceDate'])
print(f"Efficiently loaded clear information. Whole rows: {len(df)}")

Output:

Efficiently loaded clear information. Whole rows: 52933

Product Deep Dive: Who Are the True Cash Makers?

With the clear information loaded, let’s leap straight into product efficiency. Merchandise could be thought of “best-sellers” in two alternative ways: by quantity (models offered) or by worth (income generated).

Perception 2: High 10 Bestsellers (by Amount)

The amount listing tells us which merchandise are well-liked and in excessive demand, even when their worth is low. That is necessary for warehouse stocking and stock administration.

We’ll group by the product Description, sum the Amount, and kind it descendingly.

# High 10 Bestsellers (by Amount)
df.groupby(‘Description’)[‘Quantity’].sum().sort_values(ascending=False).head(10)

Output:

Description
MEDIUM CERAMIC TOP STORAGE JAR 74698
WORLD WAR 2 GLIDERS ASSTD DESIGNS 9419
GIN + TONIC DIET METAL SIGN 5016
ASSORTED COLOURS SILK FAN 4684
JUMBO BAG RED RETROSPOT 4671
PACK OF 72 RETROSPOT CAKE CASES 3561
MINI PAINT SET VINTAGE 3285
ASSORTED COLOUR BIRD ORNAMENT 2783
BROCADE RING PURSE 2525
POPCORN HOLDER 2508
Identify: Amount, dtype: int64

Perception 3: High 10 Income Drivers (The True Cash-Makers)

That is what NovaShop actually desires to know. These merchandise drive profitability. They won’t promote as many models because the gadgets within the earlier listing, however their greater worth or bigger bulk orders make them way more precious.

We observe the identical course of, however this time we mixture on the Income column we engineered in Half 1.

# High 10 Income Drivers (The True Cash-Makers)
df.groupby(‘Description’)[‘Revenue’].sum().sort_values(ascending=False).head(10)

Output:

Description
MEDIUM CERAMIC TOP STORAGE JAR 77785.74
DOTCOM POSTAGE 18456.13
REGENCY CAKESTAND 3 TIER 15093.38
AMAZON FEE 13541.33
PARTY BUNTING 9491.60
GIN + TONIC DIET METAL SIGN 9480.51
JUMBO BAG RED RETROSPOT 8996.65
Guide 8966.96
CHILLI LIGHTS 8395.20
POSTAGE 7194.51
Identify: Income, dtype: float64

Dialogue: What These Lists Inform NovaShop

That is the place the facility of EDA actually shines, as a result of these two lists inform a really totally different story:

  • The All-Star Product: The “MEDIUM CERAMIC TOP STORAGE JAR” is clearly the winner, dominating each lists by a large margin. It’s excessive quantity and excessive worth. This merchandise must be NovaShop’s major focus for stock, advertising and marketing, and enlargement.
  • A stunning income supply: Whereas exploring the info, I seen gadgets like “DOTCOM POSTAGE,” “AMAZON FEE,” “Guide,” and “POSTAGE.” These aren’t precise merchandise — they’re service charges and guide changes. But collectively, they carry in virtually £48,000 in income. NovaShop ought to double-check whether or not these charges are being counted of their gross revenue. It’s a simple factor to overlook, but it surely could possibly be a quiet and significant supply of earnings hiding in plain sight.
  • The Excessive-Worth Bodily Items: Gadgets just like the “REGENCY CAKESTAND 3 TIER” and “CHILLI LIGHTS” make the income listing however not the amount listing. This tells us they’re high-price gadgets that contribute considerably to the entire money circulate, and they’re price focused advertising and marketing efforts.

We now have an entire image of what NovaShop sells greatest. Time to determine when!

Making ready for Time-Collection Evaluation: Characteristic Engineering

We all know what offered properly. Now, let’s work out when gross sales peak. Our aim is to interrupt down the InvoiceDate column into elements that enable us to group and analyze gross sales by 12 months, month, day, and even hour.

This can be a traditional function engineering transfer. Since we already made positive InvoiceDate is a correct Pandas datetime object (because of parse_dates in our loading step!), we are able to use the extraordinarily helpful .dt accessor.

Extracting Time Elements

To know seasonality (month-to-month) and operational effectivity (hourly), we’ll create 4 new columns.

  • 12 months — For long-term comparisons
  • Month — For figuring out seasonal peaks (e.g., This autumn rush).
  • DayName — To seek out the busiest day of the week.
  • Hour — To find out peak operational hours.

Let’s generate these columns:

print(“n — — Time Collection Characteristic Extraction — -”)

# Extract 12 months, Month, DayName, and Hour from the InvoiceDate column
df[‘Year’] = df[‘InvoiceDate’].dt.12 months
df[‘Month’] = df[‘InvoiceDate’].dt.month
df[‘DayName’] = df[‘InvoiceDate’].dt.day_name()
df[‘Hour’] = df[‘InvoiceDate’].dt.hour
print(“New time options added: 12 months, Month, DayName, Hour.”)
print(df[[‘InvoiceDate’, ‘Year’, ‘Month’, ‘DayName’, ‘Hour’]].head())

Output:

--- Time Collection Characteristic Extraction ---
New time options added: 12 months, Month, DayName, Hour.
InvoiceDate 12 months Month DayName Hour
0 2011-06-01 12:05:00 2011 6 Wednesday 12
1 2011-05-27 17:14:00 2011 5 Friday 17
2 2011-04-21 17:05:00 2011 4 Thursday 17
3 2011-11-16 10:39:00 2011 11 Wednesday 10
4 2011-03-10 08:40:00 2011 3 Thursday 8

Excellent! We are able to transfer proper into mapping the gross sales patterns within the subsequent part.

Mapping Gross sales Patterns (Time-Collection Insights)

With our time options prepared, we are able to now ask and reply our questions on when gross sales happen. We’ll begin massive (month-to-month traits) and drill down small (hourly traits).

Perception 4: Gross sales Tendencies by Month (Seasonality)

Month-to-month aggregation is essential for recognizing seasonality — the predictable sample of gross sales repeating yearly. This information is used for monetary forecasting and planning stock ranges for the height season.

We’ll group by the Month column and calculate the entire income for every.

print(“n — — Perception 4: Gross sales Tendencies by Month (Seasonality) — -”)
# Group by month and sum the income
monthly_revenue = df.groupby(‘Month’)[‘Revenue’].sum().sort_values(ascending=False)
# Print the outcomes, which ought to present the seasonal peaks
print(monthly_revenue)

Output:

--- Perception 4: Gross sales Tendencies by Month (Seasonality) ---
Month
11 143576.360
1 142013.420
12 133178.980
10 119533.540
9 103929.420
3 72968.270
8 71302.890
5 70424.510
6 68722.520
7 68713.831
4 51882.010
2 50178.730
Identify: Income, dtype: float64

Interpretation: The Huge This autumn and January Shock

The information clearly exhibits that NovaShop’s gross sales are closely skewed towards the tip of the 12 months, confirming the standard retail This autumn (October, November, December) rush.

  • Peak Season: November is the height month by a slight margin, adopted intently by December. That is the time to fill up on the Medium Ceramic High Storage Jars and run focused advertisements.
  • The January Surge: The second-highest month is January! This is a superb perception for NovaShop. It suggests prospects could also be utilizing Christmas present cash or making the most of post-holiday gross sales. This era shouldn’t be handled as a droop however as a secondary high-volume gross sales alternative.
  • Low Season: February and April are the bottom performers, which helps NovaShop plan for decrease staffing and advertising and marketing budgets throughout these durations.

Perception 5: Gross sales Tendencies by Day of Week and Hour (Operational Planning)

Whereas seasonality is about finance and stock, day by day and hourly traits are about operations. NovaShop can use this to schedule warehouse workers, optimize advert spend, and time e-mail campaigns.
We’ll run two separate aggregations right here: one for the day of the week and one for the hour of the day.

Income by Day of Week

# 1. Gross sales by Day of Week
daily_revenue = df.groupby(‘DayName’)[‘Revenue’].sum()
print(“n — — Income by Day of Week — -”)
print(daily_revenue)

Output:

--- Income by Day of Week ---
DayName
Friday 163861.320
Monday 171026.230
Sunday 83125.890
Thursday 219342.980
Tuesday 282796.741
Wednesday 176271.320
Identify: Income, dtype: float64

Interpretation: Tuesday is the Energy Day

The information reveals a transparent and actionable sample for the work week:

  • Peak Gross sales: Tuesday completely dominates the week, producing virtually 30% extra income than the following busiest day, Thursday. This can be a prime day for launching new merchandise or working high-impact flash gross sales.
  • Droop Days: Unsurprisingly, gross sales drop dramatically on Sunday. NovaShop may think about this a low-priority day for e-mail advertising and marketing or customer support staffing.
  • Lacking Day: The dataset comprises no transactions for Saturday in our pattern (or maybe the complete set, which is frequent in B2B datasets).

Income by Hour of Day

# 2. Gross sales by Hour of Day
hourly_revenue = df.groupby(‘Hour’)[‘Revenue’].sum().sort_index()
print(“n — — Income by Hour of Day — -”)
print(hourly_revenue)

Output:

--- Income by Hour of Day ---
Hour
7 2830.910
8 26597.800
9 76768.750
10 209809.971
11 115233.600
12 142474.460
13 130348.290
14 119241.520
15 145178.980
16 70620.550
17 36148.030
18 14022.790
19 4397.130
20 2751.700

Interpretation: The Late Morning Increase

The hourly information factors on to operational wants:

  • Huge Peak: Gross sales explode at 10 AM (Hour 10), producing virtually double the income of the following few hours. That is the optimum time for NovaShop to launch e-mail advertising and marketing and social media campaigns.
  • Sustained Exercise: Gross sales stay excessive from 11 AM by 3 PM, suggesting a robust noon and post-lunch buying window.
  • Finish of Day: Exercise falls off sharply after 4 PM, with little or no income generated within the night (7 PM onward). This means NovaShop’s buyer base is primarily desk-based, buying throughout conventional working hours.

Conclusion: Setting the Stage for Buyer Segmentation

We have now formally completed the heavy-duty EDA! We all know what sells greatest (the Ceramic Jar and charges), the place gross sales are strongest (the UK), and when the gross sales peaks happen (This autumn, Tuesdays, and 10 AM).

Nevertheless, we’re nonetheless lacking probably the most precious piece of the puzzle: The Who. The most effective corporations don’t simply know what sells; they know who their Most worthy prospects are and methods to maintain them.

 In Half 3, we are going to dive into probably the most superior evaluation method on this collection: RFM (Recency, Frequency, Financial) Buyer Segmentation. This can enable us to categorise prospects into tiers like “Champions,” “Loyal Prospects,” and “At-Danger,” giving NovaShop a real roadmap for personalised advertising and marketing.

I hope you discovered this text useful. Be at liberty to say hello to me on any of those platforms. I actually recognize your suggestions.

Medium

LinkedIn

Twitter

YouTube

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com