1

I am looking for an efficient method in Python to check whether a particular date is an eligible day in the week. The eligible day in the week is defined as:

  1. Should be a Wednesday
  2. Should be a Business Day
  3. If the Wednesday is a holiday, then take the next available Business Day in that week

So far I have managed to find a way to determine 1. and 2., but I am struggling with the third variant.

I did the following so far:

# Import pandas as pd
is_wednesday = date_dt.weekday() == 2
is_bus_day   = bool(len(pd.bdate_range(date, date)))
if_wednesday_holiday_is_next_bus_day = ?
Usman
  • 1,983
  • 15
  • 28
WJA
  • 6,676
  • 16
  • 85
  • 152
  • Are you have holiday and business day list? – Pankaj Mar 13 '19 at 15:53
  • Yes, I have a list of business days – WJA Mar 13 '19 at 15:54
  • Holidays will be complex since they also depend on your user's country and other factors. Your best bet might be finding an API service for the same. For example, this answer https://stackoverflow.com/a/43783619/6698642 mentions how to use the Google Calendar API. – shriakhilc Mar 13 '19 at 15:55
  • So in this case, you can check the day with in your list. – Pankaj Mar 13 '19 at 15:58
  • Yes but the problem is 3, if the wednesday is a holiday in that week how do you extract the next eligible busday of that week? – WJA Mar 13 '19 at 15:59

0 Answers0