Determine if a day is a business day in Python / Pandas

后端 未结 6 1675
深忆病人
深忆病人 2021-02-13 23:06

I currently have a program setup to run two different ways. One way is to run over a specified time frame, and the other way is to run everyday. However, when I have it set to r

6条回答
  •  囚心锁ツ
    2021-02-13 23:24

    I just found a different solution to this. This might be interesting if you want to find the next business day if your date is not a business day.

       bdays=BDay()
       def is_business_day(date):
           return date == date + 0*bdays
    

    adding 0*bdays rolls forward on the next business day including the current one. Unfortunately, subtracting 0*bdays does not roll backwards (at least with the pandas version I was using).

    Moreover, due to this behavior, you also need to be careful since not necessarily 0*bdays + 1*bdays != 1*bdays

提交回复
热议问题