ID EN
Statistics

median_grouped

Python 3.11

Return the median of grouped continuous data, calculated as the 50th percentile, using interpolation. If data is empty, StatisticsError is raised. data can be a sequence or iterable.

Syntax

PYTHON
statistics.median_grouped(data, interval=1)

Examples

Example 1
PYTHON
>>> median_grouped([52, 52, 53, 54])
52.5
Example 2
PYTHON
>>> median_grouped([1, 2, 2, 3, 4, 4, 4, 4, 4, 5])
3.7
Example 3
PYTHON
>>> median_grouped([1, 3, 3, 5, 7], interval=1)
3.25
>>> median_grouped([1, 3, 3, 5, 7], interval=2)
3.5

See Also

StatisticsError median_grouped()