相关文章推荐
小眼睛的热带鱼  ·  Python equivalent of ...·  2 月前    · 
俊逸的火锅  ·  Python 控制台 — Blender ...·  2 月前    · 
健身的抽屉  ·  在 Google Cloud 上使用 ...·  2 月前    · 
直爽的黑框眼镜  ·  Difference between ...·  2 月前    · 
英勇无比的筷子  ·  Python File ...·  1 年前    · 
酒量小的充值卡  ·  DataRow ...·  3 年前    · 
爱旅游的佛珠  ·  [C#.NET ...·  3 年前    · 

如何用Python计算到日期之间的工作日?

1 人不认可

I did find this solution 点击这里查看文章 但仍不完全是我所要的。该方案计算了2个日期之间的所有天数,包括周末。那么,是否有一个解决方案可以在计算中排除周末?

1 个评论
python
Jorge Bustos Torres
Jorge Bustos Torres
发布于 2022-08-11
1 个回答
Jorge Bustos Torres
Jorge Bustos Torres
发布于 2022-08-11
已采纳
0 人赞同

因此,我所做的是采取这种解决方案,并以这种方式扩展它。

crtD = datetime.datetime.strptime(pd.loc[x,'createDate'], '%m/%d/%Y') # start date
tdyD = datetime.datetime.today() # end date
dayx = tdyD - crtD # number of days between start and end date. Includes weekends
wkds = dayx.days + 1 # eliminates time stamp and just leaves the number of days and adds 1 day