Skip to content
beginner Phase 7 · Descriptive Statistics

Measures of Central Tendency

Compare mean, median, and mode and pick the right one for skewed business data.

40m
0 problems
Topic Progress 0%

Why Central Tendency Matters

The Problem of Summarizing Data

Every dataset you encounter as a data analyst contains dozens, thousands, or millions of individual values. No stakeholder wants to look at a million rows. They want one number that answers the question: "What does a typical value look like?"

That single number is a measure of central tendency. It compresses a distribution into a representative value so you can compare groups, track changes over time, and communicate findings without overwhelming your audience.

But here is the catch: there is no single "best" measure of central tendency. The mean, median, and mode each tell a different story about the same data. Choosing the wrong one can lead to conclusions that are technically correct and practically misleading.

Consider a simple example. You are analyzing customer purchase amounts at an e-commerce store. Most customers spend between $20 and $80. A handful of wholesale customers spend $5,000 or more per order. If you report the mean purchase amount, those wholesale orders will pull the average upward, making it seem like your typical customer spends far more than they actually do. The median would give a more honest picture of what a regular customer spends.

This is not an edge case. It is the default state of most real-world data. Income distributions, housing prices, response times, hospital stay lengths, insurance claims — these are all skewed by a small number of extreme values. Understanding when each measure of central tendency is appropriate is not a theoretical exercise. It is the difference between an analysis that informs decisions and one that misleads them.

The Three Measures at a Glance

Mean — the arithmetic average. Sum all values, divide by the count. Uses every data point, which makes it sensitive to extreme values.

Median — the middle value when data is sorted. Half the values fall above it, half below. Ignores magnitude of extreme values, which makes it robust to outliers.

Mode — the most frequently occurring value. The only measure that works for categorical data. A dataset can have one mode, multiple modes, or no mode at all.

Each measure answers a different question. The mean answers "What is the arithmetic center?" The median answers "What value splits the data in half?" The mode answers "What value appears most often?" The right question depends on what you are trying to learn from the data.

A Working Example

import pandas as pd
import numpy as np

# Purchase amounts for 10 customers
purchases = pd.Series([25, 32, 45, 28, 50, 35, 42, 38, 30, 5000])

print(f"Mean:   {purchases.mean():.2f}")    # 532.50
print(f"Median: {purchases.median():.2f}")  # 36.50
print(f"Mode:   {purchases.mode()[0]}")     # No repeated values except none

The mean of $532.50 is technically correct. It is the arithmetic average of these ten purchases. But it is a terrible summary of what a typical customer spends, because nine out of ten customers spent $50 or less. The median of $36.50 is far more representative of the typical purchase.

This single example captures the entire lesson of this topic: the mean is not wrong, but it is fragile. When your data contains outliers or is heavily skewed, the median gives a more truthful summary. When your data is symmetric and free of extreme values, the mean and median will be close together, and the mean is often preferred because it uses all the information in the dataset.

Mean: The Arithmetic Average

Definition and Calculation

The mean is the sum of all values divided by the number of values. For a dataset with values x₁, x₂, ..., xₙ:

Mean = (x₁ + x₂ + ... + xₙ) / n

In pandas, you calculate it with the .mean() method:

import pandas as pd

df = pd.DataFrame({
    'department': ['Eng', 'Eng', 'Eng', 'Sales', 'Sales', 'Sales'],
    'salary': [85000, 92000, 78000, 65000, 72000, 68000]
})

# Overall mean salary
overall_mean = df['salary'].mean()
print(f"Overall mean: {overall_mean:.2f}")  # 76666.67

# Mean by department
dept_means = df.groupby('department')['salary'].mean()
print(dept_means)
# Eng: 85000.00
# Sales: 68333.33

Why the Mean Uses Every Data Point

The mean incorporates the magnitude of every value in the dataset. This is both its greatest strength and its greatest weakness.

The strength: the mean uses all available information. If you have ten values, the mean reflects the exact contribution of each one. This makes it the foundation for many statistical techniques — regression, variance, standard deviation, and hypothesis testing all build on the mean.

The weakness: because every value contributes, extreme values exert disproportionate influence. A single value that is ten times larger than the rest can shift the mean dramatically.

# Demonstrate outlier sensitivity
normal = pd.Series([10, 12, 11, 13, 12, 11, 10, 12])
with_outlier = pd.Series([10, 12, 11, 13, 12, 11, 10, 12, 1000])

print(f"Normal mean:      {normal.mean():.2f}")       # 11.38
print(f"With outlier mean: {with_outlier.mean():.2f}")  # 122.33

Adding one extreme value shifted the mean from 11.38 to 122.33 — a tenfold increase from a single data point. The median, by contrast, barely moves:

print(f"Normal median:      {normal.median():.2f}")       # 11.50
print(f"With outlier median: {with_outlier.median():.2f}")  # 12.00

When to Use the Mean

Use the mean when:

  1. The data is roughly symmetric. If the distribution has no strong skew and no extreme outliers, the mean and median will be similar, and the mean is preferred because it uses all data.
  2. You need a foundation for further analysis. Variance, standard deviation, z-scores, and many statistical tests are built around the mean.
  3. The data is interval or ratio scale. The mean requires numeric data where arithmetic operations make sense.
  4. Every value matters. In financial contexts like average revenue per user, the total revenue is the sum of all individual revenues, so the mean directly connects to the total.

When NOT to Use the Mean

Avoid the mean when:

  1. The data contains outliers. A few extreme values will distort the mean.
  2. The distribution is heavily skewed. Income, wealth, housing prices, and response times are classic examples.
  3. The data is ordinal. If values are rankings (1st, 2nd, 3rd), the mean of ranks is not meaningful.

Weighted Mean

Sometimes not all data points should contribute equally. A weighted mean assigns different weights to different values:

Weighted Mean = Σ(wᵢ × xᵢ) / Σ(wᵢ)

# Course grade: homework 30%, midterm 30%, final 40%
scores = pd.Series([85, 78, 92])
weights = pd.Series([0.30, 0.30, 0.40])

weighted_avg = (scores * weights).sum() / weights.sum()
print(f"Weighted average: {weighted_avg:.2f}")  # 85.70

The weighted mean is essential when some observations are more important or more reliable than others. Use it whenever the contribution of each value to the overall average should not be equal.

Median: The Middle Value

Definition and Calculation

The median is the value that separates the higher half of a dataset from the lower half. To find it:

  1. Sort all values in ascending order.
  2. If the count is odd, the median is the middle value.
  3. If the count is even, the median is the average of the two middle values.

In pandas:

import pandas as pd

salaries = pd.Series([45000, 52000, 48000, 61000, 55000, 50000, 58000])

print(f"Median salary: {salaries.median():.2f}")  # 52000.00

# With an even number of values
salaries_even = pd.Series([45000, 52000, 48000, 61000, 55000, 50000])
print(f"Median (even count): {salaries_even.median():.2f}")  # 51000.00

Why the Median is Robust

The median depends only on the position of values in the sorted order, not on their magnitude. Changing the largest value in a dataset — whether it is 100 or 100,000,000 — has zero effect on the median as long as it remains the largest value.

# Demonstrate robustness
data = pd.Series([20, 25, 30, 35, 40])
data_extreme = pd.Series([20, 25, 30, 35, 1000000])

print(f"Normal median:      {data.median():.2f}")        # 30.00
print(f"Extreme median:     {data_extreme.median():.2f}")  # 30.00

print(f"Normal mean:        {data.mean():.2f}")          # 30.00
print(f"Extreme mean:       {data_extreme.mean():.2f}")   # 200030.00

The median stayed at 30. The mean exploded to 200,030. This is why the median is the preferred measure for skewed data.

When to Use the Median

Use the median when:

  1. The data is skewed. Income, housing prices, transaction amounts, and response times are typically right-skewed. The median gives a more representative "typical" value.
  2. Outliers are present. If extreme values are data entry errors or genuinely anomalous cases, the median prevents them from distorting your summary.
  3. You want to describe the "middle" of the distribution. The median answers the question: "What value do half the observations exceed and half fall below?"
  4. The data is ordinal. For ranked data, the median is meaningful even when the mean is not.

Median in Practice: Income Data

Income is the canonical example of why the median matters. Consider a small company with 9 employees and 1 executive:

incomes = pd.Series([40000, 42000, 45000, 48000, 50000, 52000, 55000, 58000, 60000, 500000])

print(f"Mean income:   {incomes.mean():.0f}")    # 95000
print(f"Median income: {incomes.median():.0f}")  # 51000

The mean income of $95,000 suggests the typical employee earns close to six figures. The median of $51,000 tells the real story: half the employees earn $51,000 or less. Government agencies report median household income for exactly this reason — it is not distorted by billionaires.

Limitations of the Median

The median is not universally better than the mean. It has real limitations:

  1. It ignores magnitude. The median of [1, 2, 3, 4, 100] is 3, same as the median of [1, 2, 3, 4, 5]. The median cannot distinguish between a dataset with a moderate outlier and one with an extreme outlier.
  2. It is less stable in small samples. Adding one value can shift the median more than it shifts the mean in small datasets.
  3. It does not support further statistical analysis as cleanly. Many statistical tests are built around the mean and variance, not the median.

The median is a tool, not a default. Choose it when the data demands it, not out of habit.

Mode and Choosing the Right Measure

Definition and Calculation

The mode is the value that appears most frequently in a dataset. Unlike the mean and median, the mode works with categorical data — colors, brands, categories, any value that can be counted but not necessarily averaged.

import pandas as pd

# Numeric mode
ages = pd.Series([25, 30, 30, 35, 40, 30, 28, 35, 30])
print(f"Mode: {ages.mode()[0]}")  # 30

# Categorical mode
colors = pd.Series(['red', 'blue', 'blue', 'green', 'blue', 'red'])
print(f"Mode: {colors.mode()[0]}")  # blue

# Multiple modes (bimodal)
scores = pd.Series([1, 2, 2, 3, 4, 4, 5])
print(f"Modes: {scores.mode().tolist()}")  # [2, 4]

When to Use the Mode

Use the mode when:

  1. The data is categorical. If you are analyzing product categories, customer segments, or survey responses, the mode tells you the most common category. The mean and median are meaningless for non-numeric data.
  2. You need the most popular value. "Which product sells the most?" "What is the most common complaint category?" These are mode questions.
  3. The data is multimodal. If a dataset has multiple peaks, the mode reveals the existence of distinct subgroups. A bimodal age distribution in a dataset might indicate two distinct populations — for example, a dataset of heights that mixes men and women.

The Mode's Limitations

  1. It may not exist. If all values are unique, there is no mode.
  2. It may not be unique. A dataset can be bimodal or multimodal, making "the mode" ambiguous.
  3. It ignores all other information. The mode tells you nothing about the spread, the shape, or the other values in the dataset.

Choosing the Right Measure: A Decision Framework

The choice between mean, median, and mode depends on three factors: the type of data, the presence of outliers or skew, and the question you are trying to answer.

Step 1: What type of data do you have?

  • Categorical data → mode only
  • Ordinal data → median or mode
  • Interval/ratio data → mean, median, or mode

Step 2: Is the data symmetric or skewed?

  • Symmetric, no outliers → mean (uses all data, supports further analysis)
  • Skewed or outliers present → median (robust, representative)

Step 3: What question are you answering?

  • "What is the arithmetic center?" → mean
  • "What value splits the data in half?" → median
  • "What is the most common value?" → mode

Practical Example: Choosing for a Business Report

You are analyzing delivery times (in hours) for a logistics company:

delivery_times = pd.Series([2, 3, 2, 4, 3, 2, 5, 3, 2, 4, 3, 2, 48, 3, 2])

print(f"Mean:   {delivery_times.mean():.2f}")    # 5.87
print(f"Median: {delivery_times.median():.2f}")  # 3.00
print(f"Mode:   {delivery_times.mode()[0]}")     # 2

The 48-hour delivery is likely an anomaly — perhaps a weather delay or a data entry error. For a report to operations leadership:

  • The median (3 hours) best represents the typical delivery experience.
  • The mode (2 hours) tells you the most common delivery time.
  • The mean (5.87 hours) is distorted by the single 48-hour outlier and would mislead the audience.

But if you are calculating total delivery capacity planning, the mean matters — because total hours = mean × count, and that 48-hour delivery did consume real resources. Context determines the right measure.

Practice Problems

0 / 2 solved
Outlier Impact on Mean vs Median

Given the dataset [12, 15, 18, 14, 16, 13, 17, 15, 14, 200], calculate the mean and median. Then remove the value 200 and recalculate. Explain which measure changed more and why.

Solution
import pandas as pd

data = pd.Series([12, 15, 18, 14, 16, 13, 17, 15, 14, 200])
data_clean = data[data != 200]

print(f"With outlier - Mean: {data.mean():.2f}, Median: {data.median():.2f}")
print(f"Without outlier - Mean: {data_clean.mean():.2f}, Median: {data_clean.median():.2f}")

# With outlier: Mean = 33.40, Median = 15.00
# Without outlier: Mean = 14.89, Median = 14.50
# The mean changed by 18.51; the median changed by only 0.50
Choosing the Right Measure

For each scenario, state whether mean, median, or mode is the most appropriate measure of central tendency and explain why: (a) household income in a city, (b) most popular product category, (c) average test score in a symmetric distribution, (d) typical house price in a neighborhood with a few mansions.

Solution
(a) Median — income is right-skewed; a few high earners distort the mean.
(b) Mode — product category is categorical; only the mode works.
(c) Mean — symmetric distribution with no outliers; the mean uses all data and supports further analysis.
(d) Median — mansions are outliers that skew the mean upward; the median represents the typical house price.

Quiz

1. A dataset contains values [10, 12, 14, 16, 100]. Which measure of central tendency is most representative of the typical value?

Question 1 options

2. Which measure of central tendency is the only one that can be used with categorical data?

Question 2 options

3. Why does the median stay stable when an extreme outlier is added to a dataset?

Question 3 options

Flashcards

Question

What is the formula for the arithmetic mean?

Answer

Mean = (sum of all values) / (number of values). It uses every data point, making it sensitive to outliers.

Question

When should you use the median instead of the mean?

Answer

Use the median when data is skewed or contains outliers. The median is robust because it depends on position, not magnitude. Classic examples: income, housing prices, response times.

Question

What is the mode and when is it the only option?

Answer

The mode is the most frequently occurring value. It is the only measure of central tendency that works with categorical data (e.g., product categories, colors, brands).

Question

A dataset has values [5, 7, 7, 9, 12, 15, 200]. What are the mean and median?

Answer

Mean = 36.43 (distorted by 200). Median = 9 (the middle value). The median better represents the typical value.

Revision Notes

Key Takeaways

  • 1. The mean uses every data point, making it powerful but fragile to outliers
  • 2. The median depends on position, not magnitude, making it robust to extreme values
  • 3. The mode is the only measure that works for categorical data
  • 4. Skewed data (income, prices, response times) demands the median, not the mean
  • 5. The right measure depends on data type, distribution shape, and the question being asked

Interview Tips

  • • When asked to summarize a dataset, always check for skew and outliers before choosing mean or median
  • • Be ready to explain why median income is reported instead of mean income by government agencies
  • • If given a dataset with an extreme outlier, proactively mention how it affects the mean and why the median is more representative

Cheat Sheet

Cheat Sheet: Central Tendency

Mean

  • Formula: sum of values / count
  • Uses every data point
  • Sensitive to outliers
  • Best for: symmetric data, foundation for further stats

Median

  • Middle value in sorted data
  • Robust to outliers
  • Best for: skewed data, income, prices, response times

Mode

  • Most frequent value
  • Only measure for categorical data
  • Best for: popular category, multimodal distributions

Decision Framework

  1. Categorical data → mode
  2. Numeric + symmetric → mean
  3. Numeric + skewed/outliers → median

Code

series.mean()    # arithmetic mean
series.median()  # middle value
series.mode()    # most frequent value(s)

Continue Learning