functions for measures of central tendency¶

NumPy comes with built-in functions for common mathematical, statistical, and aggregate functions.

In [2]:
import numpy as np

create 4 lists of tempratures

In [1]:
week_1 = [45, 55, 49, 60, 52, 55, 58]
week_2 = [51, 49, 62, 50, 53, 56, 59]
week_3 = [60, 60, 61, 62, 57, 59, 58]
week_4 = [59, 63, 62, 61, 65, 66, 62]
In [3]:
# use numpy mean function
np.mean(week_1)
Out[3]:
53.42857142857143
In [4]:
# use numpy median function
np.median(week_1)
Out[4]:
55.0
In [5]:
# Mode with Python statistics' mode()
from statistics import mode
mode(week_1)
Out[5]:
55