Exploratory data analysis in Python means loading your data with pandas and asking it basic questions before any modeling: how big is it, what’s missing, what do the numbers look like, and which groups stand out. A few calls cover most of it:
df = pd.read_csv("sales_2026.csv")
df.info(); df.describe(); df.isna().sum()
df.groupby("state")["revenue"].sum()
The dataset is 600 made-up coffee shop orders from 2026, with a few problems planted on purpose, and I analyzed it with Python 3.12.5 and pandas 3.0.6.
We’ll check the structure and missing values, summarize the numbers, compare groups, find outliers, and finish with four charts that tell the story at a glance.
Step 1: Overview, data types and missing values
Start with the shape, a few rows, the column types and a count of missing values and duplicates. This tells you what cleaning you’ll need:
import pandas as pd
df = pd.read_csv("sales_2026.csv", parse_dates=["date"])
print("shape:", df.shape)
print(df.head(3).to_string())
print("\ndtypes:\n" + df.dtypes.to_string())
print("\nmissing values:\n" + df.isna().sum().to_string())
print("\nduplicate rows:", df.duplicated().sum())
Output:
shape: (601, 6)
date state category units unit_price revenue
0 2026-08-31 TX Bakery 3 4.15 12.45
1 2026-10-12 NY Beans 4 16.36 65.44
2 2026-11-14 CO Merch 2 25.86 51.72
dtypes:
date datetime64[us]
state str
category str
units int64
unit_price float64
revenue float64
missing values:
date 0
state 0
category 0
units 0
unit_price 12
revenue 0
duplicate rows: 1

Check that date is a datetime and the numbers aren’t stored as text; parse_dates handles the first. Wrong types are the most common reason later steps break.
Step 2: Summary statistics with describe()
describe() gives count, mean, spread and percentiles for each numeric column. value_counts() does the same job for categories:
# df = pd.read_csv("sales_2026.csv", parse_dates=["date"])
pd.set_option("display.float_format", "{:,.2f}".format)
print(df[["units", "unit_price", "revenue"]].describe().to_string())
print("\n" + df["category"].value_counts().to_string())
Output:
units unit_price revenue
count 601.00 589.00 601.00
mean 2.98 8.66 29.62
std 1.41 7.20 104.25
min 1.00 3.21 3.32
25% 2.00 4.29 9.69
50% 3.00 4.96 16.75
75% 4.00 13.58 26.52
max 5.00 28.67 2,499.00
category
Coffee 262
Bakery 182
Beans 83
Merch 74

Comparing the mean with the median (the 50% row) is a quick skew check. More on spread in standard deviation in Python.
Step 3: Compare groups and check correlations
After dropping the duplicate and setting the outlier aside, groupby() shows which states sell the most, and corr() shows which numbers move together:
# df = pd.read_csv("sales_2026.csv", parse_dates=["date"])
df = df.drop_duplicates()
df = df[df["revenue"] < 1000] # set the outlier aside for now
summary = df.groupby("state")["revenue"].agg(orders="count", total="sum", average="mean").round(2)
print(summary.sort_values("total", ascending=False).to_string())
monthly = df.groupby(df["date"].dt.to_period("M"))["revenue"].sum().round(2)
print("\nbest month:", monthly.idxmax(), f"${monthly.max():,.2f}")
print("\ncorrelation:\n" + df[["units", "unit_price", "revenue"]].corr().round(2).to_string())
Output:
orders total average
state
TX 173 4392.61 25.39
CA 160 3769.34 23.56
NY 116 2916.83 25.15
FL 84 2129.82 25.36
CO 66 2073.70 31.42
best month: 2026-01 $1,703.47
correlation:
units unit_price revenue
units 1.00 -0.03 0.44
unit_price -0.03 1.00 0.80
revenue 0.44 0.80 1.00

Grouping and merging go hand in hand; see merge and join in pandas and loc vs iloc in pandas.
Step 4: Find outliers with the IQR rule
A common rule flags values more than 1.5 times the interquartile range above the third quartile. Then look at the rows themselves before deciding anything:
# df = pd.read_csv("sales_2026.csv", parse_dates=["date"])
q1, q3 = df["revenue"].quantile([0.25, 0.75])
iqr = q3 - q1
high = q3 + 1.5 * iqr
print(f"Q1 ${q1:,.2f} | Q3 ${q3:,.2f} | IQR ${iqr:,.2f} | upper fence ${high:,.2f}")
outliers = df[df["revenue"] > high]
print(len(outliers), "orders above the fence; the biggest:")
print(outliers.nlargest(3, "revenue")[["date", "state", "category", "units", "revenue"]].to_string())
Output:
Q1 $9.69 | Q3 $26.52 | IQR $16.83 | upper fence $51.77
87 orders above the fence; the biggest:
date state category units revenue
5 2026-04-23 CA Beans 1 2499.00
585 2026-04-23 TX Merch 5 143.35
115 2026-04-07 TX Merch 5 135.70

Not every outlier is an error. Here, the giant order looks like a typo, while large Merch orders are just expensive items, so I’d only remove the first.
Step 5: Visualize the data
Charts catch patterns that tables hide. Four quick plots, all straight from pandas, cover the distribution, categories, trend over time and states:
# df = pd.read_csv("sales_2026.csv", parse_dates=["date"])
import matplotlib.pyplot as plt
df = df.drop_duplicates()
df = df[df["revenue"] < 1000]
fig, axes = plt.subplots(2, 2, figsize=(10, 7))
df["revenue"].plot.hist(bins=30, ax=axes[0, 0], title="Revenue per order (USD)")
df.boxplot(column="revenue", by="category", ax=axes[0, 1], grid=False)
axes[0, 1].set_title("Revenue by category"); axes[0, 1].set_xlabel("")
df.groupby(df["date"].dt.to_period("M"))["revenue"].sum().plot(ax=axes[1, 0], marker="o", title="Monthly revenue (USD)")
df.groupby("state")["revenue"].sum().sort_values().plot.barh(ax=axes[1, 1], title="Total revenue by state (USD)")
fig.suptitle("Exploratory data analysis: 2026 store sales")
plt.tight_layout()
plt.show()

An EDA checklist
- Shape, data types and a few sample rows.
- Missing values and duplicates.
describe()andvalue_counts().- Group comparisons with
groupby(). - Correlations between numeric columns.
- Outliers: find them, inspect them, then decide.
- Charts for distributions, categories and trends.
Continue with these data analysis guides:
- Multiple linear regression in Python
- K-means clustering in Python
- Mann-Whitney U test in Python
- PCA in Python
Frequently asked questions
What is exploratory data analysis in Python?
Using pandas and charts to understand a dataset’s structure, missing values, distributions, groups and outliers before modeling.
Which libraries are used for EDA in Python?
pandas for tables, matplotlib or seaborn for charts, and NumPy for calculations.
What’s the first step in EDA?
Check the shape, data types, sample rows and missing values.
Should I remove outliers?
Only after inspecting them. Remove clear errors; keep unusual but real values.
Are there tools that automate EDA?
Yes, packages like ydata-profiling generate reports, but doing it by hand teaches you the data.
Where is pandas documented?
See the pandas user guide.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes t