计算日期之间的天数,忽略周末 [英] Count number of days between dates, ignoring weekends

查看:161
本文介绍了计算日期之间的天数,忽略周末的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算两个日期之间的不考虑周末的天数?

How can I calculate number of days between two dates ignoring weekends?

推荐答案

我认为最干净的解决方案是使用numpy函数 busday_count

I think the cleanest solution is to use the numpy function busday_count

import numpy as np
import datetime as dt

start = dt.date( 2014, 1, 1 )
end = dt.date( 2014, 1, 16 )

days = np.busday_count( start, end )

这篇关于计算日期之间的天数,忽略周末的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆