Statistics Functions

statistics.median()

Find the middle sorted value, averaging the middle two for an even number of observations. Remove NaNs before sorting.

Formal Syntax & Structure

python syntaxpython
statistics.median(data)

Parameters & Attributes

NameTypeDescription
dataiterable of numbersObservations used by the statistic.

Return Value

number

Numeric result; concrete type depends on inputs.

Working Example

Example Snippetpython
import statisticsprint(statistics.median([7, 1, 3, 9]))
Python Reference