In [ ]:
#Building dataframes
ind = pd.DatetimeIndex(trip.date)
trip['weekend'] = (ind.dayofweek > 4)
by_hour_week = trip.loc[(trip.weekend==False),:].pivot_table('trip_id', aggfunc='count', index=['date'], columns=['hour']).fillna(0)
by_hour_end = trip.loc[(trip.weekend==True),:].pivot_table('trip_id', aggfunc='count', index=['date'], columns=['hour']).fillna(0)
#Visualization
plt.figure(figsize=(30,10))
ax = plt.subplot(1, 2, 1)
by_hour_week.mean().plot(kind='bar',fontsize=15)
ax.set_title('Week Days', fontsize=20)
ax.set_ylabel('Average Number of Trips',fontsize=15)
ax = plt.subplot(1, 2, 2)
by_hour_end.mean().plot(kind='bar',fontsize=15)
ax.set_title('Week Ends', fontsize=20)
ax.set_ylabel('Average Number of Trips',fontsize=15)
plt.show()