On this page
statistics.mode
Prev: statistics.median_low | Up: statistics | Next: statistics.multimode
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.mode
Tags: #public #python3 #stdlib #statistics
Import
import statistics
from statistics import mode
Signature & Overview
statistics.mode(data)
Return the most common data point from discrete or nominal data.
Usage
import statistics
assert statistics.mode(['red', 'blue', 'red']) == 'red'
Gotchas
- Returns the first-encountered winner on ties (Python 3.8+): Use
multimode()if you want all tied winners.
REPL Inspect
from statistics import mode
help(mode)
Linked from
Related notes
- tuts/python3/stdlib_module/statistics/median_low Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/multimode Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/statistics/correlation Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/covariance Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/fmean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/geometric_mean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/harmonic_mean shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde_random shared tags: #statistics, #stdlib