1. 首页
  2. Pandas

pandas显示周的完整日期

pandas周日期格式化显示

如下图所示

56205cf25293f07e84e1fe407198f642

 

代码如下:

df['weekly_ds']=pd.to_datetime(df['ds'],format='%Y%m%d').dt.to_period('W').apply(lambda r:r)

参考:

[Get week start date (Monday) from a date column in Python (pandas)? – Stack Overflow](https://stackoverflow.com/questions/27989120/get-week-start-date-monday-from-a-date-column-in-python-pandas)

发表评论

登录后才能评论