📌  相关文章
📜  pandas 根据日期类型拆分数据 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.040000             🧑  作者: Mango

代码示例1
day['hour'] = day['date_time'].dt.hour
bussiness_days = day.copy()[day['dayofweek'] <= 4] # 4 == Friday
weekend = day.copy()[day['dayofweek'] >= 5] # 5 == Saturday
by_hour_business = bussiness_days.groupby('hour').mean()
by_hour_weekend = weekend.groupby('hour').mean()

print(by_hour_business['traffic_volume'])
print(by_hour_weekend['traffic_volume'])