Interview's MateData Science
Interview's Mate

Data Science

Python → ML → MLOps

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Science topics
Lesson 41/ 160
03. Mathematics & Statistics

Descriptive Statistics (Mean, Median, Mode)

Summarize center of mass with mean/median/mode and know when each is the right story.

BeginnerMean · Median3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

The mean is what everyone would get if the total were shared equally; the median is the middle person in line; the mode is the most common value.

Think of it like…

Eight people sit in a room, seven earning ordinary salaries and one billionaire walks in. The mean salary jumps (it's the balance point, pulled toward the billionaire), while the median barely moves: it's the person in the middle of the line.

Where you’ve seen it

Monthly salaries in a team (₹ thousand): 30, 32, 35, 36, 38, 40, 42, 250. The mean is 503 / 8 = 62.9, the median is (36 + 38) / 2 = 37, and there's no single mode. A report saying "average salary ₹62,900" overstates what 7 of 8 people earn because of the one 250. Reporting the median (37) plus the mean and the top value tells the full story, and a 12.5%-trimmed mean (dropping the highest and lowest) of 37.2 agrees with the median.

Words you’ll hear

Mean (average)
Sum of values divided by the number of values; sensitive to outliers.
Median
Middle value of the sorted data; robust to outliers.
Mode
Most frequent value; works for categorical data and can be multimodal.
Trimmed mean
Mean after dropping a fixed share of the lowest and highest values.

Visual diagram

Loading interactive diagram

Theory & deep dive

What each statistic tells you

The mean uses all values and has nice mathematical properties (totals, regression, the CLT), but a single extreme value can move it a lot. The median depends only on order, so it's stable under outliers, and half of the observations lie on each side. For symmetric distributions they coincide; for right-skewed ones (income, prices, durations) mean > median, for left-skewed ones the opposite, so comparing them is a quick skewness check. The mode identifies the most common category or value; a histogram showing two peaks (bimodal) usually means two subpopulations, where any single average is misleading.

Variants for special cases: the weighted mean (np.average(x, weights=w)) for unequal group sizes, the geometric mean for multiplicative growth (average of 10%, 20% and −5% annual returns is not their arithmetic mean), the harmonic mean for averaging rates such as speeds over equal distances, and the trimmed mean (scipy.stats.trim_mean(x, 0.1)) as a compromise between mean and median.

Average of rates

A trip of 60 km at 30 km/h and 60 km at 60 km/h takes 2 h + 1 h = 3 h for 120 km, so the average speed is 40 km/h, the harmonic mean, not the arithmetic mean of 45.

Key takeaway: Mean for totals and symmetric data, median for skewed data, mode for categories.

In pandas: missing values and groups

s.mean(), s.median() and s.mode() skip NaN by default (skipna=True), so the number of values behind the statistic may be smaller than the row count: report s.count() alongside. s.mode() returns a Series because there can be several modes. df.groupby("city")["amount"].agg(["count", "mean", "median"]) produces side-by-side group summaries, and df.describe() gives count, mean, quartiles and extremes at once.

Don't average averages: the mean of group means equals the overall mean only when groups are the same size. Be careful with means of percentages and ratios (compute from the underlying sums), and be explicit about what is excluded (zeros? test accounts? refunds?). When a distribution is skewed, show the median and a high percentile (p90, p95) alongside the mean; for categorical columns use value_counts(normalize=True).

A compact summary

df["delivery_min"].agg(["count", "mean", "median", lambda s: s.quantile(.9)]) gives n, the average, the typical and the "bad-day" experience in one line.

Key takeaway: Report the count, the median and a tail percentile, and never average averages.

How it works, step by step

Step 1 of 4
Explore

1. Look at the distribution

Plot a histogram or box plot and check counts and missing values before computing summaries.

hist · boxplot · count()
Key numbers at this step
Shape
first

When to use it & trade-offs

What it is

Three numbers summarise where a variable is centred. The mean is the sum divided by the count; it uses every value but is pulled by extremes. The median is the middle value of the sorted data (the average of the two middle values when n is even); it ignores how far the extremes are. The mode is the most frequent value, the only one that works for categories. Which to report depends on the shape of the data and the question: the mean is natural for totals and symmetric data, the median for skewed data such as income or delivery time.

Why it matters: "The average salary is ₹63,000" and "the typical salary is ₹37,000" can both be true of the same data, and choosing the wrong one misleads decisions. Every dashboard, A/B test and model starts with these summaries. Knowing how outliers affect each statistic, and how pandas treats missing values, avoids the most common reporting mistakes.

When to reach for it

  • Median for income, price and duration reporting
  • Mean for totals, rates and symmetric measurements
  • Mode for most common category or size

When to avoid or be careful

  • Reporting only the mean of a skewed variable
  • Averaging group averages of unequal sizes
  • Computing statistics without checking the count and missing values

Measures of centre

Mean
Best for: Symmetric data and totals

Strengths: Uses all data; foundation of many methods.

Watch out: Distorted by outliers and skew.

Median
Best for: Skewed data and robust reporting

Strengths: Resistant to extremes.

Watch out: Ignores magnitude of tails; less algebra-friendly.

Mode
Best for: Categorical data and discrete counts

Strengths: Works for non-numeric data.

Watch out: May be non-unique or unstable for continuous data.

Interview signals & numbers to know

When this topic comes up

  • “The average looks wrong”
  • “Mean vs median: which would you report?”
  • “Average speed over two legs”
  • Outlier sensitivity
  • Weighted averages

Benchmarks & rules of thumb

62.9 vs 37 -
mean vs median in the salary example
40 km/h -
harmonic-mean average speed in the trip example
skipna=True -
pandas default for missing values

Common mistakes & follow-ups

Common interview mistakes

  • Reporting an average salary dragged up by one executive as "typical".
  • Using the arithmetic mean of speeds over equal distances.
  • Averaging per-store conversion rates without weighting by traffic.

Likely interviewer follow-ups

  • When would you report the median instead of the mean?
  • How do mean and median tell you about skew?
  • How do you average growth rates correctly?
Interview tip: Always say which statistic and why, and mention n. "Median of 37 across 8 people; the mean is 62.9 because of one outlier" is a complete, credible sentence.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Descriptive Statistics (Mean, Median, Mode) with data science interview Q&A and hands-on practice.

Open Data Science Q&A →Machine Learning Q&A
Previous topic
Big Data Processing with PySpark
Next topic
Variance, Standard Deviation & IQR