Paul's Python CoursePPC

Project 8 of 12, for Yahya

Summary Statistics Report

A summary statistics report on the Clocktower station's 2024, for the summary sheet in the Archive: the middle day, the usual day, the spread and the readings that don't fit.

About 70 minutes, in 15 steps.

Sign up free to open itLog in

Act 5 needs a free account, so your work is saved as you go. Act 1 is open to everyone.

The brief

  • YahyaThe station's summary sheet does the whole year in one line, and it says average daily rain is 2.6 millimetres.
  • YahyaMost days it didn't rain at all, so that average day never actually happened.
  • PaulThen give it more than one number.
  • YahyaLet's give it six and say which is which, and find me the readings that don't belong while we're at it.

daily.csv is the Clocktower station's 2024, one row per day: date, rain (mm), temp (degrees C) and thornby, the temperature at Thornby's station, twenty miles out of the city.

Write four functions. Each takes a Series of readings and leaves it as it was.

  • summary(values): a dictionary with the keys mean, median, mode (the most common value; the smallest, if several tie), std (the standard deviation, as pandas works it out), q1 and q3 (the quartiles: a quarter of the readings are at or below q1, three quarters at or below q3).
  • fences(values): the low and high fences, as a pair: q1 minus one and a half times q3 - q1, and q3 plus the same.
  • outliers(values): the readings below the low fence or above the high one, as a Series that keeps their labels.
  • dry_days(rain, threshold=0.2): how many days had less rain than the threshold.
What it prints
Rain on an average day: 2.6 mm. On the middle day: 0.3 mm.
Most common: 0.0 mm. Dry days: 160 of 366
Clocktower: average 12.7 degrees C, standard deviation 4.3
Thornby: average 12.7 degrees C, standard deviation 6.3
Outside the fences:
  Clocktower, 2024-06-14: 41.3 degrees C
  Thornby: 0 readings
  Rain: 38 days

What you learn

What's in it

  1. Three kinds of average
  2. An average week
  3. How far from the middle
  4. Two kinds of spread
  5. Quarters of the pile
  6. A quarter of the way up
  7. The shape of a year
  8. One long wait
  9. A year, day by day
  10. Readings that don't fit
  11. Outside the fences
  12. How Paul would do it
  13. Make the summary sheet's numbers
  14. Ship it