text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

cityTable = pd.read_csv('../input/city_attributes.csv')
temperatureDF = pd.read_csv('../input/temperature.csv', index_col=0)
temperatureDF.index = pd.to_datetime(temperatureDF.index)
cityTable

citiesToShow = ['Los Angeles', 'Chicago', 'Montreal', 'Houston']
t0 = temperatureDF.index
t1 = pd.date_range(pd.to_datetime('1/7/2015', dayfirst=True), pd.to_datetime('1/10/2016', dayfirst=True), freq='H')
t2 = pd.date_range(pd.to_datetime('1/7/2015', dayfirst=True), pd.to_datetime('1/9/2015', dayfirst=True), freq='H')
t3 = pd.date_range(pd.to_datetime('1/7/2015', dayfirst=True), pd.to_datetime('21/7/2015', dayfirst=True), freq='H')
fig, ax = plt.subplots(nrows=4, ncols=1, figsize=(20, 15))
temperatureDF.loc[t0, citiesToShow].plot(ax=ax[0])
temperatureDF.loc[t1, citiesToShow].plot(ax=ax[1], legend=False)
temperatureDF.loc[t2, citiesToShow].plot(ax=ax[2], legend=False)
temperatureDF.loc[t3, citiesToShow].plot(ax=ax[3], legend=False)
ax[0].legend(loc='upper left', fontsize=20, bbox_to_anchor=(0.02, 1.3), ncol=len(citiesToShow))
for i in range(len(ax)):
    ax[i].set_ylabel('Temperature [$^\\circ$K]', fontsize=15)
plt.tight_layout()