Quantcast
Channel: Business Hours Between Two Dates in Pandas Dataframe (including holidays) - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Andy Hayden for Business Hours Between Two Dates in Pandas Dataframe (including holidays)

$
0
0

You could use the length of bdate_range:

In [11]: pd.bdate_range('2017-01-01', '2017-10-23')Out[11]:DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04', '2017-01-05','2017-01-06', '2017-01-09', '2017-01-10', '2017-01-11','2017-01-12', '2017-01-13',               ...'2017-10-10', '2017-10-11', '2017-10-12', '2017-10-13','2017-10-16', '2017-10-17', '2017-10-18', '2017-10-19','2017-10-20', '2017-10-23'],              dtype='datetime64[ns]', length=211, freq='B')In [12]: len(pd.bdate_range('2017-01-01', '2017-10-23'))Out[12]: 211

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>