Univariate Analysis
Meet every column as an individual
One variable at a time, told properly: categorical frequencies, numeric distributions, quantiles, and the story a histogram plus a box plot reveals.
What you will learn
- Summarize categoricals with value_counts
- Read histogram + boxplot + stats together
- Describe skew, spread and typical value per variable
What is this?
Univariate analysis studies each column alone. Categoricals: value_counts with missing-aware normalization. Numerics: describe (mean, percentiles, std), a histogram of shape, and a box plot of spread and outliers. Reading them together tells you typical value, variability, skew, and clustering before any relationship is examined.
Why do you need it?
- A single column can discredit an analysis — negative prices, massive outliers, bimodal mixes.
- Knowing each distribution informs which summary is honest (median vs mean).
- Distribution shapes hint at transformations and model assumptions down the line.
- It is the vocabulary every subsequent bivariate chart depends on.
Mental model
Reading each file in a cabinet before organizing the drawer
Univariate analysis
The archivist opens each folder (column), notes size, shape and odd pages before trying to file things by relation. Univariate is that per-file inspection — the folder's own story first.
How it works
- Categorical: df[col].value_counts(dropna=False) shows frequencies including its 'missing' bucket.
- Numeric: df[col].describe() gives count, mean, std, min, quartiles, max.
- Histogram visualizes shape: bell, skewed, bimodal, uniform.
- Box plot visualizes spread and fence-outliers at a glance.
- Compare mean vs median: divergence means skew — mean-shown, median-true.
- Log-scaling or bucketing reveals structure in heavy-tailed numeric columns.
One column, four views.
Examples
Reading one column like a pro
import numpy as np, pandas as pdamt = pd.Series(np.random.default_rng(2).lognormal(3, 1.0, 500))print((amt.describe())[['count','mean','50%','75%','max']].round(2))print("mean vs median gap:", round(amt.mean() - amt.median(), 2))print("skewed right -> report the median")The mean-median gap is the skew tell: a log-normal column says 'median, not mean' as your headline.
In production
- A funnel analyst finds 'billing amount' is multimodal (two plan tiers) and segments before any funnel math.
- An ops dashboard reports p50/p95 latency from univariate inspection, not the mean.
- A feature pipeline logs each column's skew to choose log-vs-lin transformations.
Best practices
- Pair each numeric column with its histogram + box + describe in the same report block.
- Report the median when mean-median diverge; say why.
- Always mount dropna=False counts for categoricals so absence is visible.
- Bucketed views (histogram bins) should adapt to the data, not default counts.
Common mistakes
- Summarizing a categorical with mean() and wasting the insight.
- Ignoring bimodality that flags two populations blended together.
- Reporting the mean of a heavy-tail column without the median.
- Assuming the histogram is bell-shaped without actually squinting at it.
Debugging tips
- A mean far outside the IQR range → look at the top 1% values, not the mean itself.
- value_counts showing a 99% single value → near-constant column, drop from models.
- Missing bucket visible → completeness problem, not a value problem.
- Log-transform the histogram of money data; the shape usually snaps into focus.
Interview checkpoint
Hands-on lab
- Classify each column as categorical or numeric
- Summarize both with stats + counts
- Write the 'want to report'/transformation notes
Profile Every Column of a Churn File
30 min · beginner
Quick quiz
Skew in a column is best detected by:
A bimodal histogram means every column must be normalized immediately.