Data Preparation / Data Preprocessing Slides 📂 Introduction · 2 of 13 39 min read

Exploratory Data Analysis (EDA) with Pandas

Before you model, you interrogate. EDA is getting to know a dataset — its shape, types, distributions, gaps, and relationships — one pandas command at a time. This tutorial walks the workflow: the first-look commands (head, info, describe), mapping missing values and duplicates, and climbing from univariate to bivariate to multivariate analysis, always paired with plots — with animated diagrams.

🔍

Exploratory Data Analysis with Pandas

Before you model, you interrogate. EDA is the detective work of getting to know a dataset — its shape, types, distributions, gaps, and relationships — one pandas command at a time.
Inspect Summarize Distributions Relationships

Press Next → or use ← → arrow keys

Section 01

The Intuition — Meet Your Data First

A detective walks the scene before naming a suspect
A good detective doesn't accuse anyone on arrival — they walk the scene, note what's there, spot what's missing, and let the evidence raise the questions. Jumping to a conclusion before looking is how cases go wrong.

Exploratory Data Analysis (EDA) is that walk-through for a dataset. Before any model, you read the data, understand its structure and types, compute summary statistics, and look for patterns, gaps, and oddities — so the questions you ask next are the right ones.
💡
What EDA Is For

EDA has three goals: understand the structure (rows, columns, types), assess quality (missing values, duplicates, outliers), and surface patterns (distributions and relationships). It turns a raw table into a mental model you can actually reason about.

Section 02 · The Process

The EDA Workflow

1 · Loadread_csv / read_sql 2 · Inspecthead · info · shape 3 · Check qualitymissing · dupes 4 · Univariatedistributions 5 · Bi/Multirelationships 6 · Insightshypotheses ✓
🔁
Loop, Don't March

EDA isn't a straight line — a surprising distribution sends you back to check quality; a suspicious correlation prompts a new plot. You cycle through inspect → question → visualize until the dataset holds no more surprises. The output is a set of hypotheses worth testing, not a final answer.

Section 03 · First Look

The First Five Commands

import pandas as pd
df = pd.read_csv("data.csv")

df.head()        # first 5 rows — what does a record look like?
df.shape         # (rows, columns) — how big is it?
df.info()        # dtypes + non-null counts — types & missingness at a glance
df.dtypes        # is 'age' really numeric, or read as object?
df.describe()    # count, mean, std, min, quartiles, max (numeric cols)
👀
Read Before You Compute

These five calls answer the essentials in seconds: what a row looks like (head), how large the data is (shape), which columns have missing values and wrong types (info, dtypes), and the shape of every numeric column (describe). Never skip this — a column silently read as text instead of a number breaks everything downstream.

🏷️
Add describe(include='object') For Categories

Plain describe() covers only numeric columns. Pass include='object' (or 'all') to see count, unique, top, and frequency for text/categorical columns too.

Section 03 · Summaries

Summarizing Every Column

🔢
Numeric → describe()
Count, mean, std, min, 25/50/75%, max. The gap between mean and median instantly flags skew.
🏷️
Categorical → value_counts()
How many of each category, and their balance. Add normalize=True for proportions.
🧮
Grouped → groupby()
Split-apply-combine: df.groupby('region')['sales'].mean() compares a metric across groups.
df['category'].value_counts()                 # counts per category
df['category'].value_counts(normalize=True)  # proportions
df.groupby('region')['revenue'].agg(['mean', 'median', 'count'])
Section 04 · Quality

Missing Values & Duplicates

id age income city score isnull().sum() id 0 age 1 inc 3 score 1
🕳️
Find The Gaps Before They Find You

df.isnull().sum() counts missing values per column; df.duplicated().sum() catches repeated rows. Here income is the worst offender (3 gaps). Don't fix them yet — EDA's job is to map the damage so the cleaning step knows where to focus.

Section 05 · Depth

Univariate → Bivariate → Multivariate

Univariate · 1 variable "what does one column look like?" Bivariate · 2 variables "how do two columns relate?" Multivariate · many "how do all columns interact?"
🪜
Three Depths Of Looking

Univariate studies one column at a time (histograms, value_counts). Bivariate pairs two (scatter, groupby, a single correlation). Multivariate looks at many together (correlation matrix, pairplot). Work up the ladder — each level answers a bigger question.

Section 05 · Univariate

One Column, Fully Understood

outlier same column, as a box plot
📊
Histogram For Shape, Box Plot For Outliers

A quick df['col'].hist() reveals the shape — here a right skew — while df['col'].plot.box() exposes the spread and outliers. For categorical columns, value_counts().plot.bar() does the same job. Univariate analysis answers: is it skewed? bimodal? riddled with outliers? capped?

Section 05 · Bivariate

How Two Columns Relate

Numeric × Numeric
Scatter plot + df['a'].corr(df['b']). Shows direction, strength, and non-linearity.
📦
Numeric × Category
groupby('cat')['num'].mean() or a box plot per category — compares distributions across groups.
🔲
Category × Category
pd.crosstab(a, b) tallies co-occurrence; normalize it for conditional proportions.
df.groupby('plan')['monthly_spend'].mean()   # numeric by category
pd.crosstab(df['region'], df['churned'])       # category vs category
df['age'].corr(df['income'])                    # one correlation
Section 05 · Multivariate

Everything At Once

# correlation matrix across all numeric columns
corr = df.corr(numeric_only=True)

import seaborn as sns
sns.heatmap(corr, annot=True, cmap='coolwarm')   # the whole picture
sns.pairplot(df, hue='target')                     # every pair scattered
🌐
The Correlation Heatmap Is The Payoff

One df.corr() heatmap surfaces every strong relationship at a glance: which features track your target (keep them), and which features mirror each other (redundant — a multicollinearity warning). A pairplot then lets you eyeball each pair's actual shape, catching the non-linear patterns a single correlation number would miss.

🎨
Colour By The Target

Adding hue='target' to a pairplot colours points by class — instantly showing which features actually separate your groups, a huge head-start on feature selection.

Section 06 · Visual Toolkit

Which Plot For Which Question?

QuestionPlotpandas / seaborn
Shape of one numeric columnHistogramdf['x'].hist()
Spread & outliers of one columnBox plotdf['x'].plot.box()
Counts of a categoryBar chartvalue_counts().plot.bar()
Relationship of two numericsScatterdf.plot.scatter('a','b')
A numeric across categoriesGrouped boxsns.boxplot(x,y)
All pairwise relationshipsHeatmap / pairplotsns.heatmap(df.corr())
👁️
Numbers Lie; Pictures Confess

Summary statistics can hide skew, outliers, and non-linearity — remember Anscombe's Quartet. Pair every describe() with a plot. A five-second histogram catches problems a table of means would let slip straight into your model.

Section 07 · Pitfalls

EDA Traps To Sidestep

❌ The Trap✅ The Fix
Skipping straight to modellingAlways inspect + plot first — GIGO applies here too
Trusting describe() aloneVisualize; stats hide skew & outliers
Ignoring dtypes (numbers read as text)Check df.dtypes; cast early
Treating correlation as causationEDA raises hypotheses, doesn't prove them
Cleaning during explorationMap issues now; fix them in the cleaning step
🧭
Explore To Understand, Not To Conclude

EDA's output is a map of the data and a list of questions — not final answers. A striking pattern is a hypothesis to test later, not a proven fact. Keeping that mindset stops you from fooling yourself early.

Section 08 · Golden Rules

Six Rules For EDA

🏅 EDA With Pandas, Distilled
1Always look before you model. head → info → describe is non-negotiable step one.
2Check dtypes early. A numeric column read as text quietly breaks everything downstream.
3Map missing values & duplicates with isnull().sum() and duplicated() — before cleaning.
4Climb the ladder: univariate → bivariate → multivariate, each answering a bigger question.
5Always visualize. Numbers hide what a quick histogram, box plot, or heatmap reveals.
6Produce hypotheses, not verdicts. EDA points you where to look — testing comes later.
Wrap-Up

You Can Now Interrogate Any Dataset

headFirst look
infoTypes + nulls
describeSummary stats
isnullMap the gaps
corrRelationships
plot!Always visualize
🎯
The Through-Line

EDA is the disciplined first look: load the data, inspect its structure and types, map its quality problems, then climb from single columns to relationships — always pairing statistics with plots. Done well, it hands the rest of your pipeline a clear map and a sharp set of questions.

📚
Where To Go Next

EDA surfaces the problems; data cleaning fixes them — missing values, duplicates, outliers, and type errors. After that comes feature engineering and transformation, turning your now-understood data into model-ready inputs.

🔍 End of tutorial · Press to review, or click Restart