pandas splitting the data based on the day type

Solutions on MaxInterview for pandas splitting the data based on the day type by the best coders in the world

showing results for - "pandas splitting the data based on the day type"
Eisley
09 Oct 2019
1day['hour'] = day['date_time'].dt.hour
2bussiness_days = day.copy()[day['dayofweek'] <= 4] # 4 == Friday
3weekend = day.copy()[day['dayofweek'] >= 5] # 5 == Saturday
4by_hour_business = bussiness_days.groupby('hour').mean()
5by_hour_weekend = weekend.groupby('hour').mean()
6
7print(by_hour_business['traffic_volume'])
8print(by_hour_weekend['traffic_volume'])