statistics.median()
statistics.median() is a Python function in the Statistics Module category. Returns the median (middle value) of numeric data. The syntax is statistics.median(data). Returns: Float or int. A typical example: statistics.median([1, 3, 5]) # 3
statistics.median([1, 3, 5, 7]) # 4.0 (average of 3 and 5). A close sibling is statistics.mean(), which returns the arithmetic mean (average) of numeric data. A close sibling is statistics.median_low(), which returns the low median of numeric data (for when there are an even number of values). A close sibling is statistics.median_high(), which returns the high median of numeric data. A close sibling is statistics.mode(), which returns the most common data point. Raises StatisticsError if no unique mode. More about this category: Statistical functions — mean, median, mode, stdev, correlation. For a broader walkthrough, read the Statistics Module guide. Related Statistics Module entries: statistics.mean(), statistics.median_low(), statistics.median_high(), statistics.mode(), statistics.multimode(), statistics.stdev().