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

后端 未结 6 1684
深忆病人
深忆病人 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:48

    Since len of pd.bdate_range() tells us how many business days are in the supplied range of dates, we can cast this to a bool to determine if a range of a single day is a business day:

    def is_business_day(date):
        return bool(len(pd.bdate_range(date, date)))
    

提交回复
热议问题