pandas从时间序列中判断是一周的第几天或星期几

在这里插入图片描述

#把时间列标准化时间格式
df['time_slot1']=pd.to_datetime(df['time_slot1'])
#输出这一天是周中的第几天,Monday=0, Sunday=6
df['dayofweek']=df['time_slot1'].dt.dayofweek

猜你喜欢

转载自blog.csdn.net/weixin_35770067/article/details/132818112