The mode is the most frequently occurring value in a dataset. It's the only measure of central tendency that works directly on categorical data — you can't "average" or "sort" city names, but you can absolutely count which one appears most.
What Makes the Mode Different From Mean and Median
Mean needs numeric magnitude. Median needs a meaningful order (numeric or ordinal). Mode needs neither — it only needs the ability to check whether two values are equal, which is why it's the natural summary statistic for purely nominal categories like payment method, city, or product type. A dataset can also have more than one mode (bimodal, multimodal) or, if every value is unique, no mode at all.
Formula / Definition
In plain terms: find the value \(x\) whose count (frequency) in the dataset is the highest, and that value is the mode.
Graphical Intuition
The mode is simply the tallest bar in a frequency chart — the category that occurs most often.
Step-by-Step Numerical Example
Seven students' exam scores: \(62, 68, 68, 72, 75, 80, 85\).
| Value | Count |
|---|---|
| 62 | 1 |
| 68 | 2 |
| 72 | 1 |
| 75 | 1 |
| 80 | 1 |
| 85 | 1 |
68 appears twice, more than any other value — the mode is 68.
Categorical Example — Where the Mode Really Belongs
Payment methods for 10 transactions: UPI, Cash, UPI, Card, UPI, Wallet, Cash, UPI, Card, UPI. Counting: UPI appears 5 times, Cash 2 times, Card 2 times, Wallet 1 time. The mode is UPI — and notice there's no meaningful "mean" or "median" payment method at all; mode is the only one of the three that applies here.
Python Implementation
# From scratch
from collections import Counter
def mode_from_scratch(data):
counts = Counter(data)
max_count = max(counts.values())
return [value for value, count in counts.items() if count == max_count]
scores = [62, 68, 68, 72, 75, 80, 85]
print(mode_from_scratch(scores)) # [68]
payments = ["UPI", "Cash", "UPI", "Card", "UPI", "Wallet", "Cash", "UPI", "Card", "UPI"]
print(mode_from_scratch(payments)) # ['UPI']
# NumPy / Pandas / SciPy
import pandas as pd
from scipy import stats
print(pd.Series(scores).mode()) # 0 68
print(pd.Series(payments).mode()) # 0 UPI
print(stats.mode(scores, keepdims=True)) # ModeResult(mode=array([68]), count=array([2]))
Unimodal, Bimodal and Multimodal Data
A dataset with one clear peak in its frequency distribution is unimodal. A dataset with two roughly equally common peaks is bimodal — for example, website session durations might cluster around "2 minutes" (quick bounces) and "20 minutes" (engaged visits), with relatively few sessions in between. Bimodal data is an important signal: it often means your dataset is secretly a mix of two different underlying groups, which is exactly the kind of pattern clustering is built to discover.
The Empirical Relationship Between Mean, Median and Mode
For moderately skewed unimodal distributions, there's a useful rule of thumb:
This isn't an exact law, but it captures a real pattern: in a right-skewed distribution (like income), you'll typically see Mode < Median < Mean, in that order — the mode sits at the most common (usually lower) value, the mean gets dragged furthest toward the long tail, and the median sits in between.
Practical Use Cases
- Mode imputation — the standard way to fill missing values in a categorical column
- Identifying the most common category in a feature during EDA (most common city, most common product category)
- A simple "always predict the most common class" baseline for classification — useful for sanity-checking that your real model actually beats trivial guessing
Advantages
- The only central tendency measure that works on purely nominal categorical data
- Unaffected by extreme values, since it only cares about frequency, not magnitude or rank
Limitations
- Can be undefined (no repeated values) or ambiguous (multiple values tied for most frequent) on some datasets
- Ignores everything about the data except which value repeats most — two very differently shaped distributions can share the same mode
- Less useful for continuous numeric data, where exact value repeats are rare (binning into ranges is usually needed first)
Common Mistakes
- Trying to compute a mode for continuous numeric data without binning it first — with enough decimal precision, almost no value repeats exactly, making a literal mode meaningless.
- Assuming a dataset always has exactly one mode — it can have zero (all unique) or several (a tie).
- Using mode imputation on a numeric feature by mistake, when mean or median would preserve more of the feature's actual distribution.
Interview Relevance
Q: "Why can't you compute a mean or median for a 'favorite color' survey column?" Because mean requires numeric magnitude and median requires a meaningful order, and colors have neither — only counting frequency (the mode) is a valid summary for purely nominal categorical data.
Q: "What would a bimodal distribution in a feature suggest to you?" That the data may actually be a mixture of two distinct underlying groups (e.g. two customer segments behaving differently) rather than one homogeneous population — worth investigating with clustering or by checking if another variable explains the split.
Practice Question
A dataset of shoe sizes is: \([7, 8, 8, 9, 9, 9, 10]\). Find the mode by hand, and explain why mode, not mean, is often reported alongside "most common size" in retail inventory planning.