Tuesday, June 12, 2018

Quick and easy statistics with Python 3

Today I discovered that Python 3 (starting with 3.4) includes a new module in the standard library: statistics!

The full docs: https://docs.python.org/3/library/statistics.html

It is a useful library for quick explorations in the terminal. Fire an iPython shell, gather some data in a list, e.g. k, and then:

In [8]: import statistics

In [9]: statistics.mean(k)
Out[9]: 354.2944444444444

In [10]: statistics.stdev(k)
Out[10]: 29.47088274648779