Menu
CoddyTech

Recap: Rainfall Report

Part of the Data and Plots section of Coddy's Machine Learning journey. Lesson 30 of 60.

challenge icon

Challenge

Medium

Remember the report that opened this chapter? Build it now. A cycling club asks which weekday is usually the wettest; rain holds 42 days in a row (mm), six weeks starting on a Monday.

  1. Average each weekday over the six weeks.
  2. Print Wettest: and the name of the weekday with the highest average.
  3. Draw two charts side by side: bars of the weekday averages named by weekdays, and a histogram of the daily rain with 5 bins.

Yours should look like this one, from another station:

Two charts side by side: left, bars titled Rain by Weekday, Weekday across and Average rain (mm) up; right, a histogram titled Daily Rain, Rain (mm) across and Days up

Use these texts: Rain by Weekday, Weekday and Average rain (mm) on the left; Daily Rain, Rain (mm) and Days on the right. For that station the program prints Wettest: Thu, then Coddy describes the figure.

Try it yourself

import numpy as np
import matplotlib.pyplot as plt

# Rain per day (mm), 6 weeks of 7 days, starting on a Monday
rain = np.array([0, 0, 3, 12, 5, 0, 0, 1, 0, 0, 0, 2, 8, 0,
                 14, 25, 6, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 1,
                 0, 7, 18, 9, 0, 0, 2, 5, 0, 0, 0, 11, 3, 0])
weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

# Write your code below

All lessons in Data and Plots

Practice on your own: Online Python compiler