Descriptive statistics
Mean, median and spread — and when the mean is the wrong summary.
Before you start
Given a column of 1000 numbers, you can't look at each one. You need summaries — single numbers that stand in for the whole column. **Descriptive statistics** are those summaries.
The three you use most: **mean** (add everything up, divide by count), **median** (sort and pick the middle), and **standard deviation** (how spread out from the mean the values are). They agree when data is nice. They disagree — and reveal problems — when it isn't.
This lesson shows what happens when one outlier lands in the data. The mean gets pulled far from typical. The median doesn't budge. That gap is often the whole story.
scores
one value far from the restNine values cluster near 75. One is 300. How do you summarise this?
Step 1 of 6. Ten scores, one outlier. Nine scores cluster between 55 and 90. One score is 300 — far outside the range. Whether it is a mistake or a legitimate value, it is going to distort any summary that uses it. The goal of descriptive statistics is to compress these ten numbers into one or two that capture what is typical.
Step 01 / 06
Ten scores, one outlier
Nine scores cluster between 55 and 90. One score is 300 — far outside the range. Whether it is a mistake or a legitimate value, it is going to distort any summary that uses it.
The goal of descriptive statistics is to compress these ten numbers into one or two that capture what is typical.
import pandas as pdscores = pd.Series([55, 70, 72, 75, 78, 80, 82, 85, 90, 300])scores.mean() # 88.7 — pulled up by 300scores.median() # 79.0 — unaffected by 300scores.std() # 69.1 — high, because of 300# describe() gives all of them at oncescores.describe()# count 10.0# mean 88.7# std 69.1# min 55.0# 25% 71.5# 50% 79.0 ← median# 75% 83.75# max 300.0# After removing the outlierclean = scores[scores < 200]clean.mean() # 76.3clean.median() # 76.5 — almost equal → symmetric