Distributions: hist, kde, box
Seeing the shape of one variable.
Distributions: hist, kde, box is a free Data Science Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Data Science Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
See the Shape of One Column
Before averages, look at the whole spread. A distribution plot shows how often each value appears across a single column.
The Histogram
A histogram drops values into bins and draws a bar for each. Tall bars mark the values that show up most often.
sns.histplot(data=df, x="age")Bins Change the Story
Too few bins hide detail, too many add noise. Adjusting bins tunes how coarse or fine the histogram looks.
sns.histplot(data=df, x="age", bins=20)A Smooth Curve: KDE
A KDE plot draws a smooth curve instead of bars, estimating the density of values. It reveals the overall shape at a glance.
sns.kdeplot(data=df, x="age")Histogram Plus KDE Together
Want both the bars and the smooth line? Add kde=True to a histogram and seaborn overlays the curve for you.
sns.histplot(data=df, x="age", kde=True)Read the Peaks
One hump means a single common range, two humps hint at two groups. The number of peaks often signals hidden subgroups in your data.
The Box Plot
A box plot squeezes the distribution into five numbers: the median, the middle half, and the reach of the data.
sns.boxplot(data=df, y="income")Read the Box and Whiskers
The line inside is the median, the box is the middle 50 percent, and the whiskers stretch toward the typical extremes.
Spot Outliers Instantly
Dots beyond the whiskers are flagged as outliers. Box plots make these unusual values jump right off the screen.
Compare Groups Side by Side
Add a category to x and the box plot splits by group. Now you can compare the spread of income across each team at once.
sns.boxplot(data=df, x="team", y="income")Which Plot, When?
Reach for a histogram or KDE to see shape, and a box plot to compare groups and catch outliers fast.
Quick Check
You want to compare spread across categories and spot outliers.
Recap: Three Views of One Column
You can now read a column three ways: histograms for counts, KDE for smooth shape, and box plots for spread and outliers. 📈
Frequently asked questions
Is the “Distributions: hist, kde, box” lesson free?
Yes — the full text of “Distributions: hist, kde, box” is free to read here on the web, and the Data Science Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Data Science Academy course, upgrade to CoddyKit PRO.
What will I learn in “Distributions: hist, kde, box”?
Seeing the shape of one variable. You practise Data Science Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Data Science Academy?
No prior experience is required. Data Science Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Distributions: hist, kde, box” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Data Science Academy lesson?
Yes. Every Data Science Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why seaborn Over Raw matplotlib
- Distributions: hist, kde, box
- Relationships: scatter and line
- Facets, Hue, and Style