Data: basic statistics
Before any analysis, we summarise the data. The statistics module gives the mean (mean), the median (median, the middle value once sorted), the mode (the most frequent one) and the standard deviation (stdev, how far values spread from the mean).
The mean is sensitive to extreme values: a single price of €90 pulls it up, while the median barely moves. Comparing the two is a data scientist's reflex for spotting odd data.
import statistics as st
temperatures = [18, 21, 19, 25, 30, 22, 21]
print("mean:", round(st.mean(temperatures), 1))
print("median:", st.median(temperatures))
print("mode:", st.mode(temperatures))
print("std dev:", round(st.stdev(temperatures), 2))