In [ ]:
# Count trips by date
serie=trip.date.value_counts()
serie=dict(date=serie.index,count_trips=serie.values)
by_date=pd.DataFrame(serie, columns=['count_trips'], index=serie['date'])
by_date=by_date.sort_index(axis=0)
by_date['Mean_Temperature_F']=weather['Mean_Temperature_F']
In [ ]:
# Visualization
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
plt.style.use('ggplot') #common style used through the project
%matplotlib inline
ax = by_date.plot(fontsize=20,secondary_y=['Mean_Temperature_F'],figsize=(30,10));
ax.set_title('Temperature Influence on the Daily Number of Trips',fontsize=25)
ax.legend(loc=2,fontsize=20)
ax.right_ax.legend(loc=1,fontsize=20)
ax.set_ylabel('Daily Trips Count', fontsize=20)
ax.right_ax.set_ylabel('Mean Temperature (F)', fontsize=20)
plt.show()