There are no items in your cart
Add More
Add More
| Item Details | Price | ||
|---|---|---|---|
Before you build a single machine learning model, your data has a story to tell. This guide walks you through every stage of EDA — from your first look at raw data to the insights that shape your final model — with real code, visuals, and the mistakes most beginners make.
|By Affordable AI, Nagpur
Exploratory Data Analysis, or EDA, is the process of investigating a dataset before you draw conclusions from it or feed it into a model. Instead of jumping straight to predictions, you slow down and ask simple questions: What does this data actually contain? Are there gaps? Do the numbers make sense? Which variables move together?
Statistician John Tukey, who popularized the term in the 1970s, treated data analysis the way a detective treats a case — gather evidence first, form a theory second. That mindset is exactly what separates a reliable model from one that quietly fails in production because nobody noticed a broken sensor, a currency mismatch, or a column full of typos.
EDA is not a single command you run — it's a habit of curiosity applied in a structured order. Below is that order, broken into nine practical steps you can follow on any dataset, in any industry.
Each step builds on the one before it. Skipping ahead is how avoidable errors end up baked into a final model.
Every dataset exists to answer a question. Are you predicting customer churn, diagnosing a machine fault, or measuring the impact of a marketing campaign? Write that question down in one sentence before opening your notebook.
This step also means learning where the data came from — surveys, sensors, transaction logs, web forms — because the source tells you what kind of noise and bias to expect later. A field collected by a rushed call-centre agent behaves very differently from one logged automatically by a machine.
Load the dataset and check its shape, column names, and data types before anything else. This single step catches a surprising number of problems — a numeric column stored as text, a date field that didn't parse correctly, or a file that loaded with the wrong number of rows.
import pandas as pd
df = pd.read_csv("sales_data.csv")
print(df.shape) # rows, columns
print(df.dtypes) # data type of each column
df.head() # first 5 rows
df.info() # nulls + memory usage in one view
Missing data is rarely random. A blank "income" field might mean the customer skipped a sensitive question, or a null "delivery_date" might mean the order was cancelled. Before filling anything in, measure how much is missing and look for a pattern in where it's missing.
df.isnull().sum()
df.isnull().mean() * 100 # percentage missing per column
# Common strategies
df["age"].fillna(df["age"].median(), inplace=True)
df.dropna(subset=["customer_id"], inplace=True)
As a rule of thumb: a column missing more than ~40–50% of its values is often better dropped than imputed, unless that column is critical to your question.
Duplicate rows quietly inflate counts and skew averages. Mismatched data types — like a price stored as a string with a currency symbol — silently break every calculation downstream. Clean both before you write a single chart.
df.duplicated().sum()
df.drop_duplicates(inplace=True)
df["price"] = df["price"].str.replace("₹", "").astype(float)
df["order_date"] = pd.to_datetime(df["order_date"])
Now look at one column at a time. For numeric columns, check the mean, median, and spread. For categorical columns, check the value counts. This is where you spot skewed distributions, rare categories, and values that don't belong — like an "age" of 250.
df.describe() # numeric summary
df["category"].value_counts() # category frequencies
import seaborn as sns
sns.histplot(df["price"], kde=True)
sns.boxplot(x=df["category"])
Distribution and boxplot views like these reveal skew and spread at a glance.
Once you understand each column individually, look at how pairs of columns relate. Does spend increase with age? Does churn rate change by region? A correlation matrix and a heatmap are the fastest way to scan dozens of relationships at once.
corr = df.corr(numeric_only=True)
sns.heatmap(corr, annot=True, cmap="coolwarm")
sns.scatterplot(x="marketing_spend", y="revenue", data=df)
A word of caution: correlation tells you two variables move together, not that one causes the other. Ice cream sales and drowning incidents both rise in summer — the real driver is heat, not each other.
Outliers can be genuine (a rare million-dollar transaction) or errors (a negative age). The Interquartile Range (IQR) method is a simple, reliable way to flag them before deciding whether to cap, remove, or keep them as-is.
Q1 = df["revenue"].quantile(0.25)
Q3 = df["revenue"].quantile(0.75)
IQR = Q3 - Q1
lower = Q1 - 1.5 * IQR
upper = Q3 + 1.5 * IQR
outliers = df[(df["revenue"] < lower) | (df["revenue"] > upper)]
With the individual pieces understood, bring them together. Pair plots, grouped bar charts, and time-series line plots often reveal patterns that no single number can — a seasonal spike, a segment that behaves differently, or a trend that reverses over time.
sns.pairplot(df[["age", "income", "spend", "churn"]], hue="churn")
df.groupby("region")["revenue"].mean().plot(kind="bar")
Close the loop by writing down what you found: which columns were dropped and why, which values were imputed, which relationships look meaningful, and which questions remain open. This summary becomes the map that guides feature engineering and model selection — and it's what you'll thank yourself for six months from now when someone asks "why did we do it this way?"
"A model built on unexamined data is a guess dressed up in decimals. EDA is what turns that guess into something you can defend."
You don't need dozens of libraries — these five cover almost every EDA task you'll run into.
Loading, cleaning, filtering, and summarizing tabular data — the backbone of every EDA workflow.
The standard pairing for histograms, boxplots, heatmaps, and scatter plots in Python.
Fast numerical operations that power calculations across large arrays and columns.
Auto-generate a full EDA report in one line — great for a first pass on a new dataset.
Interactive charts you can zoom, filter, and hover through — useful for shareable dashboards.
The workspace where code, charts, and notes live side by side as you explore.
Skipping EDA to save time usually costs more time later, fixing a model that failed for reasons hidden in the raw data.
Some "outliers" are your most important data points — fraud cases, top customers, or rare failures.
A strong correlation is a lead to investigate, not a conclusion to report as fact.
Without notes, no one — including future you — can reproduce or trust the analysis.
EDA isn't a box to check before the "real" work of modeling begins — it is the real work. Every step above, from spotting a missing value to reading a correlation heatmap, builds the judgment you need to trust what a model tells you later. The more datasets you walk through this process, the faster the pattern-spotting becomes second nature.
Start with one dataset this week. Run through all nine steps, even if it feels slow the first time. That discipline is what separates analysts who guess from analysts who know.