On this page
statistics.median
Prev: statistics.mean | Up: statistics | Next: statistics.median_grouped
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.median
Tags: #public #python3 #stdlib #statistics
Import
import statistics
from statistics import median
Signature & Overview
statistics.median(data)
Return the median (middle value) of numeric data.
Usage
import statistics
assert statistics.median([1, 3, 5]) == 3
assert statistics.median([1, 2, 3, 4]) == 2.5
Gotchas
- Averages the two middle values for even-length inputs (use
median_low/median_highfor non-numeric orderable data).
REPL Inspect
from statistics import median
help(median)
Linked from
Related notes
- tuts/python3/stdlib_module/statistics/mean Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/median_grouped 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