import pandas as pd
from pandas import Series
import matplotlib.pyplot as plt
temperature = pd.read_csv(
"https://milliams.com/courses/data_analysis_python/cetml1659on.txt", # file name
skiprows=6, # skip header
delim_whitespace=True, # whitespace separated
na_values=['-99.9', '-99.99'], # NaNs
)
The only difference from the decade example is that
(temperature.index // 10) * 10
has changed to
(temperature.index // 100) * 100
century = (temperature.index // 100) * 100
temperature['century'] = century
by_century = temperature.groupby('century').mean()
ax = by_century["YEAR"].plot.bar()
ax.set_ylabel(r'Temperature ($^\circ$C)')
plt.show()