← Back to list

Python for Data Science — Mean, Median, Mode, and When They Mislead

Data science is often associated with machine learning, coding, and visualization.

Sudha Rani Maddala · 2026-06-29 11:27 · 3 claps · 3.4 min read
#python #data-science #statistics #machine-learning #data-analysis
Open on Medium ↗
Wiki topics: ML · Machine Learning EDU · Education & Learning 💻 · Programming 🔒 · Cybersecurity 📐 · Mathematics 🔬 · Science · General

Python for Data Science — Mean, Median, Mode, and When They Mislead

Data science is often associated with machine learning, coding, and visualization.

But underneath all of those topics lies something even more fundamental:

Statistics.

Statistics helps us summarize data, understand patterns, measure uncertainty, and make better decisions.

The good news is that, as a data scientist, you do not need to become a mathematician.

You need practical statistics — the kind that helps you understand real datasets and avoid common analytical mistakes.

Hope you enjoyed the first blog in **Statistics for data science.**

The goal is not to memorize formulas. The goal is to understand what the numbers are actually telling us.

Why Summary Statistics Matter

Imagine you’re given a dataset containing customer salaries.

The first question most people ask is:

What is the typical salary?

To answer that, we often use summary statistics such as:

  • Mean
  • Median
  • Mode

These are called measures of central tendency because they help describe the center of the data.

They sound simple.

But using the wrong one can lead to misleading conclusions.

The Mean

The mean is what most people call the average.

It is calculated by adding all values and dividing by the number of observations.

For example:

Data:

10, 20, 30, 40, 50

Mean:

The mean uses every value in the dataset.

This makes it useful, but also sensitive to extreme values.

When the Mean Misleads

Consider this salary dataset:

3000
3500
4000
4500
100000

The average salary becomes much higher because of one extreme value.

If you reported only the mean, you might conclude:

Employees typically earn a very high salary.

But that would not accurately describe most employees.

This is one reason analysts do not blindly trust averages.

The Median

The median is the middle value when data is arranged in order.

Example:

10, 20, 30, 40, 50

Median:

30

Half the values are below it.

Half the values are above it.

Unlike the mean, the median is much less affected by extreme values.

Why Analysts Love the Median

Let’s revisit the salary example:

3000
3500
4000
4500
100000

Median:

4000

This provides a much more realistic picture of what most employees earn.

This is why median is commonly used for:

  • income analysis
  • housing prices
  • customer spending
  • financial data

where extreme values are common.

The Mode

The mode is the value that appears most frequently.

Example:

10, 20, 20, 20, 30, 40

Mode:

20

Unlike mean and median, the mode focuses on frequency.

When Mode Is Useful

Mode is especially useful for categorical data.

For example:

The mode tells us:

Card is the most common payment method.

This type of insight cannot be obtained from a mean or median.

Comparing the Three

Suppose we have:

10, 20, 20, 30, 100

Mean:

36

Median:

20

Mode:

20

Notice how different the mean is.

The extreme value (100) pulls it upward.

This illustrates why choosing the correct measure matters.

Which One Should You Use?

There is no universally best option.

It depends on the data.

Use Mean When:

  • Data is fairly balanced.
  • Extreme values are not a major concern.

Use Median When:

  • Outliers exist.
  • Data is skewed.

Use Mode When:

  • Working with categories.
  • Understanding the most common value matters.

A Common Beginner Mistake

Many beginners automatically calculate the mean and stop there.

But experienced analysts ask:

Does the mean actually represent the data?

Sometimes it does.

Sometimes it doesn’t.

The answer depends on the distribution.

Real-World Example

Imagine a city where:

  • Most homes cost between $200,000 and $400,000.
  • A few luxury properties cost several million dollars.

The mean home price may appear extremely high.

The median often provides a more realistic representation of the market.

This is why many real estate reports use median prices instead of averages.

Thinking Like an Analyst

Beginners often ask:

What is the average?

Analysts ask:

What statistic best represents the data?

That difference is important.

Because statistics are not just calculations.

They are tools for understanding reality.

And the wrong tool can create the wrong conclusion.

What’s Next?

Mean, median, and mode tell us where the center of the data is.

But they do not tell us how spread out the data is.

For example:

Two datasets can have the same average while behaving very differently.

To understand variability, we need two important concepts:

  • Variance
  • Standard Deviation

We’ll explore those in the next article.

Key Takeaway

Mean, median, and mode are useful summaries of data, but each tells a different story. Good analysts choose the measure that best reflects the data rather than relying on averages alone.


메타데이터
post_id
b35c454f5c8b
slug
python-for-data-science-mean-median-mode-and-when-they-mislead-b35c454f5c8b
url
https://medium.com/@sudhamsr/python-for-data-science-mean-median-mode-and-when-they-mislead-b35c454f5c8b
canonical_url
https://medium.com/@sudhamsr/python-for-data-science-mean-median-mode-and-when-they-mislead-b35c454f5c8b
author_url
https://medium.com/@sudhamsr
status
ok
fetched_at
2026-07-09 17:12:49