statistics (PyPI backport for Python 2.x)

1.0.3.5 · abandoned · verified Thu Apr 16

This PyPI package provides a backport of the Python 3.4 `statistics` module for Python 2.x environments. It offers functions for calculating mathematical statistics of numeric (real-valued) data, mirroring the functionality introduced in Python 3.4's standard library. For Python 3.4 and newer, the `statistics` module is built directly into Python and this PyPI package is not needed and generally should not be installed.

Common errors

Warnings

Install

Imports

Quickstart

Calculate basic statistics (mean, median, mode, standard deviation) from a list of numeric data. This example code uses the `statistics` module, which is built-in for Python 3.4+ and provided by the PyPI package for Python 2.x. It's assumed the appropriate version of Python (3.4+ built-in or Python 2 with the PyPI package) is in use.

import statistics

data = [1.5, 2.5, 3.5, 4.5, 5.5]

mean_value = statistics.mean(data)
median_value = statistics.median(data)
mode_value = statistics.mode(data)
stdev_value = statistics.stdev(data)

print(f"Mean: {mean_value}")
print(f"Median: {median_value}")
print(f"Mode: {mode_value}")
print(f"Standard Deviation: {stdev_value}")

view raw JSON →