Is there a better or more direct way to calculate this than the following?
What gives pandas.tseries.index.DatetimeIndex
DatetimeIndex(['1986-01-01', '1986-01-20', '1986-02-17', '1986-05-26', '1986-07-04', '1986-09-01', '1986-10-13', '1986-11-11', '1986-11-27', '1986-12-25', '1987-01-01', '1987-01-19', '1987-02-16', '1987-05-25', '1987-07-03', '1987-09-07', '1987-10-12', '1987-11-11', '1987-11-26', '1987-12-25'], dtype='datetime64[ns]', freq=None, tz=None)
But you need a list for numpy busday_count
holiday_date_list = holidays.date.tolist()
Then, with and without holidays, you get:
np.busday_count(start_date.date(), end_date.date()) >>> 521 np.busday_count(start_date.date(), end_date.date(), holidays = holiday_date_list) >>> 501
There are several other questions that are a bit similar, but usually work with the pandas Series or Dataframes ( Get working days between start and end dates using pandas , Counting business days between two series )