Arthur D. Howland
Arthur D. Howland

Reputation: 4557

Python3 Count Number of Week Days Ignoring Holidays

Testing one of my scripts it appears that Numpy busday_count includes Labor Day (September 2nd). Is there a way to disable the holidays?

print (np.busday_count('2019-08-31', '2019-09-02'))

Result = 0, but 9/2/2019 is clearly Labor Day and a Monday.

print (np.busday_count('2019-08-31', '2019-09-03'))

Result = 1, but it should be 2. As far as I know the formula excludes the first date but includes the second date. I also tried:

print (np.busday_count('2019-08-31', '2019-09-02', holidays=[]))

Result still = 0 despite attempt to clear any holidays. What am I missing?

Upvotes: 0

Views: 114

Answers (1)

sammy
sammy

Reputation: 867

As so often, the answer lies with the documentation and Python's love for half-open intervals:

Counts the number of valid days between begindates and enddates, not including the day of enddates.

Upvotes: 1

Related Questions