Recap: Rainfall Report
Part of the Data and Plots section of Coddy's Machine Learning journey. Lesson 30 of 60.
Challenge
MediumRemember 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.
- Average each weekday over the six weeks.
- Print
Wettest:and the name of the weekday with the highest average. - 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:
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
2NumPy Arrays
Creating ArraysShape and SizeRanges of NumbersIndexing and SlicingRecap: Temperature GridPractice on your own: Online Python compiler