Data Analysis · Tutorial 6 of 6
Statistics Basics for Analysts: mean, median and spread
By the FUTEAC Team · 20 November 2026 · 13 min read · Beginner
In short
Mean, median and spread tell you what a set of numbers is saying. The mean is the average, the median is the middle value, and the standard deviation measures how far numbers usually sit from the mean. This tutorial works them out on ten days of shop sales, shows why one day moves the mean and leaves the median alone.
- The mean is the ordinary average. Add the numbers up, divide by how many there are. It uses every value, which is its strength and its weakness.
- The median is the middle value. Sort the numbers and take the one in the middle. One extreme value cannot drag it around, which makes it honest for skewed data like salaries.
- Spread matters as much as the centre. Two shops can average the same daily sales and behave very differently. Range, variance and standard deviation tell you how much the numbers jump around.
- Standard deviation is the spread number you will actually use. It is in the same units as your data, so "sales vary by about 7 rupees" means something, and "variance is 43" does not.
- Always report the median next to the mean. If the two are far apart, the data is skewed, and the mean on its own will mislead whoever reads your report.
- This tutorial feeds the Spreadsheets for Data Analysis course (/course/spreadsheets-for-data-analysis) and the Statistics Basics (/skill/statistics-basics) skill.
Before you start
What statistics does for an analyst
A shopkeeper with ten days of sales figures has a problem. Ten numbers do not fit in a sentence, and a manager will not read a table of ten numbers either. Statistics solves the problem by shrinking the ten numbers into two or three that still say something true: a typical day, and how much days vary.
Think of it like describing a cricket team with two numbers instead of eleven player profiles. The average score tells you how good the team usually is. The spread tells you whether they score about the same every match or swing between a century and a collapse. One number without the other is half a description, and a report built on half a description is how bad decisions get made.
The data for this tutorial is ten days of sales from a small stationery shop, in rupees:
120, 135, 128, 142, 130, 138, 125, 131, 137, 129Every number in this tutorial comes from that list, worked out by hand first and checked against Python second. Nothing here is a made-up example. Run the code yourself and you will get the same answers.
---
The mean: add them up, divide
The mean is the number most people mean when they say "average". Add all ten sales together and divide by ten:
120 + 135 + 128 + 142 + 130 + 138 + 125 + 131 + 137 + 129 = 1315
1315 / 10 = 131.5The shop averages 131.5 rupees of sales a day. In Python, one line does the same job:
import statistics
sales = [120, 135, 128, 142, 130, 138, 125, 131, 137, 129]
print(statistics.mean(sales))131.5Hand and machine agree, which is the point of doing it by hand once. If you only ever call the function, you never learn what it is doing, and you cannot spot the day it gives you a wrong answer for a right-looking reason.
The mean uses every value in the list. That is why it is the default average, and it is also why it is fragile. Change one number and the mean moves. How much it moves is the subject of section 6.
---
The median: the middle value
The median is the value in the middle when the numbers are sorted. Sort the ten sales:
120, 125, 128, 129, 130, 131, 135, 137, 138, 142With ten numbers there is no single middle one, so the median is the average of the fifth and sixth values, 130 and 131:
(130 + 131) / 2 = 130.5In Python:
print(statistics.median(sales))130.5The median is 130.5, almost the same as the mean of 131.5. When the two sit close together, the data is roughly symmetric: as many days sit above the middle as below it, and no single day is pulling the average far from the centre. That closeness is itself a finding. It tells you the mean is safe to quote for this shop, this week.
The median ignores how far away the extreme values are. A day of 142 and a day of 1,000 both count as "one day above the middle". That is what makes the median stubborn, and stubborn is what you want when the data has a wild day in it.
A third average exists, the mode, the value that appears most often. It earns one honest paragraph and no more. Every value in our list appears exactly once, so there is no real mode, and Python's statistics.mode() simply returns the first value it meets, 120, which is not an answer to any question. Only quote a mode when a value genuinely repeats, like the most common shoe size in a shop's orders. For numbers that rarely repeat, the mode is the wrong tool.
---
Spread: range, variance and standard deviation
The mean says a typical day brings in 131.5 rupees. It says nothing about whether days swing between 50 and 300 or sit quietly between 120 and 142. That is what spread measures, and there are three ways to say it.
The range is the simplest: highest minus lowest.
142 - 120 = 22Sales ranged over 22 rupees across the ten days. The range is easy and it is weak, because it uses only two numbers out of ten. One wild day can double the range while the other nine days stay calm.
Variance is the careful measure. It takes each day's distance from the mean, squares it, and averages the squares:
(120 - 131.5)^2 = 132.25
(135 - 131.5)^2 = 12.25
(128 - 131.5)^2 = 12.25
(142 - 131.5)^2 = 110.25
(130 - 131.5)^2 = 2.25
(138 - 131.5)^2 = 42.25
(125 - 131.5)^2 = 42.25
(131 - 131.5)^2 = 0.25
(137 - 131.5)^2 = 30.25
(129 - 131.5)^2 = 6.25
Sum of squares = 390.5
390.5 / 9 = 43.39The variance is 43.39. Two details deserve attention. The distances are squared so that days below the mean do not cancel days above it: without squaring, the distances would sum to zero every time. And the sum is divided by 9, not 10. When your ten days are a sample of a longer run of trading, statisticians divide by one less than the count, which corrects a small bias. Python's statistics.variance() does exactly that.
The standard deviation is the square root of the variance, and it is the spread number you will actually report, because it is back in rupees:
print(statistics.variance(sales))
print(statistics.stdev(sales))
print(statistics.pstdev(sales))
print(max(sales) - min(sales))43.388888888888886
6.587024281789835
6.248999919987197
22Read the output as a sentence: daily sales average 131.5 rupees and typically sit about 6.59 rupees away from that average. That sentence is what a manager can use. "Variance is 43.39" is not, because 43.39 is in squared rupees, a unit nobody thinks in.
The third line, pstdev, is the population version, 6.25. It divides by 10 instead of 9, and it is the right choice only when your ten days are the whole population you care about, not a sample of more trading. Our opinion: use stdev, the sample version, unless you are certain your data is the complete set. For a shop that keeps trading, it never is.
---
Quartiles and the IQR: where the middle half sits
Quartiles split the sorted data into four equal parts. The second quartile is the median, 130.5. The first quartile is the point a quarter of the way through, and the third quartile is the point three quarters through:
print(statistics.quantiles(sales, n=4))[127.25, 130.5, 137.25]So the first quartile is 127.25, the median is 130.5, and the third quartile is 137.25. The gap between the first and third quartiles is the interquartile range, the IQR:
137.25 - 127.25 = 10The IQR says the middle half of the shop's days fell between 127.25 and 137.25 rupees, a band 10 rupees wide. It is the spread measure that ignores extremes entirely: the best day and the worst day do not touch it. Analysts use it when they want to describe the ordinary run of days without letting one wild day into the sentence.
---
The wrong turn: one value, no spread, and the outlier that moves the mean
The first wrong turn is asking for a spread from a single number. A new shop has one day of sales so far, 142 rupees, and the owner wants the standard deviation:
print(statistics.stdev([142]))Python answers:
Traceback (most recent call last):
...
statistics.StatisticsError: stdev requires at least two data pointsSpread is a comparison between numbers. With one number there is nothing to compare it against, so the function refuses instead of inventing an answer. The same refusal meets an empty list: statistics.mean([]) raises StatisticsError: mean requires at least one data point. Both errors are Python telling you the question has no answer, not that your code is broken. The fix is to wait until you have data, or to report the single value plainly as "one day of sales: 142", with no statistics attached.
The second wrong turn is subtler, and it is the reason this tutorial exists. An eleventh day arrives, and it is a festival day: 480 rupees, nearly four times a normal day. Add it to the list and compute the two averages again:
sales_with_outlier = sales + [480]
print(statistics.mean(sales_with_outlier))
print(statistics.median(sales_with_outlier))163.1818181818182
131The mean jumps from 131.5 to 163.18, a rise of nearly a quarter, because of one day. The median moves from 130.5 to 131, barely a flicker, because the festival day is simply one more day above the middle. The shop did not get 24 percent better. One day was extraordinary, and the mean let that day speak for all eleven.
This is the most common statistics mistake in business reporting, and it usually arrives disguised as good news. Average salary in a company with one very highly paid director, average house price in a street with one mansion, average order value in a week with one bulk buyer: in each case the mean is technically correct and practically misleading. Our opinion: report the median next to the mean whenever the data can have a wild value, and if the two disagree by a lot, trust the median for "typical" and explain the gap in one sentence.
---
The same numbers in a spreadsheet
Not every analyst reaches for Python, and the same five numbers come out of a spreadsheet with five formulas. Put the ten sales in cells A1 to A10, then:
| What you want | Excel formula | Google Sheets formula |
|---|---|---|
| Mean | =AVERAGE(A1:A10) | =AVERAGE(A1:A10) |
| Median | =MEDIAN(A1:A10) | =MEDIAN(A1:A10) |
| Sample standard deviation | =STDEV.S(A1:A10) | =STDEV(A1:A10) |
| Lowest day | =MIN(A1:A10) | =MIN(A1:A10) |
| Highest day | =MAX(A1:A10) | =MAX(A1:A10) |
The results are 131.5, 130.5 and 6.59, the same as Python gave. Quartiles need =QUARTILE.INC(A1:A10, 1) and =QUARTILE.INC(A1:A10, 3) in Excel, and =QUARTILE(A1:A10, 1) and =QUARTILE(A1:A10, 3) in Sheets. If your spreadsheet and your Python disagree, check the data first, not the formulas. A mistyped number in the list is a more likely cause than a bug in either tool.
---
Try it yourself
Work through these with the same ten sales, first by hand, then in Python: 1. Drop the best day, 142, and the worst day, 120, from the list. Compute the mean and the median of the eight days that remain. Both should barely move, and that stability is the point: with well-behaved data, the two averages agree. 2. Replace the 142 with 200, a good day but not a festival. Compute the mean and median again. The mean should rise to about 137.3 and the median should stay at 130.5. Write one sentence explaining the difference to a shopkeeper who has never heard of a median. 3. Take the sales of a second shop: [60, 200, 80, 190, 100, 170, 90, 180, 70, 175]. Compute its mean, median and standard deviation. Its mean is exactly the same as the first shop's, 131.5, but its standard deviation is 55.88, against 6.59 for the first shop. Write two sentences a manager could use: one about the typical day, one about how jumpy the days are. If step 3 surprises you, you have learned the lesson that matters most in this tutorial: two shops can share an average and be completely different businesses.
Continue in the free course: Spreadsheets for Data Analysis →
Common mistakes
- Quoting the mean for skewed data. Average salary or house price with one extreme value makes the typical case look richer than it is. Report the median next to the mean, and say which one describes a typical case.
- Mixing up sample and population standard deviation.
statistics.stdev()divides by n minus 1,statistics.pstdev()divides by n. For our ten days they give 6.59 and 6.25. Usestdevunless your data is the complete population, and say which one you used. - Reporting variance as if it were in the original units. Variance is 43.39 squared rupees, not 43.39 rupees. Report the standard deviation, 6.59 rupees, when you want a number a reader can picture.
- Asking for spread from one value or an average from none.
statistics.stdev([142])raisesStatisticsError: stdev requires at least two data points, andstatistics.mean([])raisesStatisticsError: mean requires at least one data point. Both mean the question has no answer yet. - Trusting
modewhen nothing repeats. With ten distinct values,statistics.mode()returns 120, the first value it meets, which is not a finding. Only quote a mode when a value genuinely repeats. - Forgetting the data was dirty. A duplicated row or a 480 typed as 4800 changes the mean before any formula runs. Clean the data first, using the checklist in item 34, then summarise it.
Frequently asked questions
Do I need Python to do basic statistics?
No. A spreadsheet gives you the same answers with AVERAGE, MEDIAN and STDEV.S, and for a one-off summary that is the faster route. Python earns its place when the same summary must run every week on fresh data, or when the data lives in files and APIs rather than a sheet.
What is the difference between variance and standard deviation?
Variance is the average squared distance from the mean, 43.39 here. Standard deviation is its square root, 6.59, back in the original units. Variance is the stepping stone, standard deviation is the number you report, because "sales vary by about 7 rupees" means something to a reader and "variance is 43" does not.
When should I use the median instead of the mean?
When the data can have extreme values: salaries, house prices, order values, waiting times. If the mean and the median are close, quote either. If they are far apart, quote the median for "typical" and explain the gap. The gap itself is information: it tells you the data is skewed.
What does the IQR tell me that the range does not?
The range uses only the highest and lowest values, so one wild day controls it. The IQR covers the middle half of the data, 127.25 to 137.25 here, and ignores the extremes. Use the range for a quick sense of the full span and the IQR when you want the ordinary run of days.
Is a standard deviation of 6.59 big or small?
It depends on the mean. Here it is about 5 percent of 131.5, so days are steady. The same 6.59 against a mean of 20 would be a third of the average, which is wild. Always read spread next to the centre it belongs to, never on its own.
Follow the Data Analyst Roadmap
Turn raw data into decisions with spreadsheets, SQL, Python and dashboards. Free, step by step, at your pace.
View the Roadmap