Time series in Pandas can be indexed and sliced in many different ways, but it cannot be with integer indexes. Our index is dates, remember? Thus, to get all the data within the year 1988, we simply index with that year as a string. In the following code, we index it with the year 1988 and then plot the values:
temp['1988'].plot(lw=1.5) despine(plt.gca()) plt.gcf().autofmt_xdate() plt.minorticks_off() plt.ylabel('Temperature');
The plot shows how the temperature varied over the year 1988, going from almost -30 to roughly +25 and then back to below zero around late October. As you probably suspected, you can also index to a whole month, by just giving the year and month:
temp['1988-01'].plot(ls='dotted', marker='.') despine(plt.gca()) plt.gcf().autofmt_xdate() plt.ylabel('Temperature');
The variation within one month, here January, is quite large, around 20 degrees from minimum to maximum. You can also slice with...