"Average" sounds like one number, but there are three common kinds, and they can tell very different stories about the same data.
The three averages
- Mean: add all values and divide by the count.
- Median: sort the values and take the middle one (or the mean of the middle two).
- Mode: the most frequent value.
import numpy as np
from statistics import mode
bills = np.array([180, 220, 220, 250, 300, 340, 4200])
bills.mean() # pulled up by the 4,200 bill
np.median(bills) # 250
mode(bills) # 220Why they differ: skew
When data is symmetric, the three are close. When it has a long tail, they separate:
- Right-skewed data (a few very large values: incomes, order values, delivery times, house prices) has mean > median.
- Left-skewed data (a few very small values: scores on an easy test) has mean < median.
In the bills above, one bulk order lifts the mean far above what a typical customer spends.
When to use each
Mean
- Data is roughly symmetric without extreme outliers.
- You need totals to reconcile: mean × count = total. Finance often needs this.
- Inputs to further calculations, such as averages per unit.
Median
- Skewed data or data with outliers: salaries, order values, waiting times, property prices.
- Describing the "typical" case for people. "Half of customers waited less than X minutes" is easy to understand.
Mode
- Categories: the most common payment method, size or complaint type.
- Discrete values with a clear peak: the most common basket size.
Report more than one number
Averages hide spread. Two branches can have the same median delivery time but very different reliability. Pair the average with:
- Percentiles (25th, 75th, 90th).
- The minimum and maximum, or a box plot.
- The count, so readers know how much data sits behind it.
In SQL and Excel
- SQL:
AVG(x)for the mean. Many databases offerPERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x)or aMEDIANfunction. - Excel:
AVERAGE,MEDIAN,MODE.SNGL.
A common trap: average of averages
If one store had 10 orders with an average of ₹500 and another had 1,000 orders averaging ₹300, the overall average is not ₹400. It is much closer to ₹300, because the second store has far more orders. Compute overall averages from the raw data or weight by counts.
Practise
Compute all three on real arrays in our NumPy statistics set and see skew directly in the distributions set. For the bigger picture, read statistics for data analysts.
Practise what you just read
Reading helps; writing the code yourself is what sticks. Start here: