finding last business day of a month in python

前端 未结 6 1130
半阙折子戏
半阙折子戏 2020-12-31 08:33

I\'m trying to find last business day of of the month. I wrote the code below for that and it works fine but I was wondering if there is a cleaner way of doing it?

6条回答
  •  再見小時候
    2020-12-31 09:09

    Let's say you want to get the last business days of the month up-to the end of the next two years, the following will work.

       import pandas as pd
       import datetime
    
       start = datetime.date.today()
       end = datetime.date(start.year+2, 12, 31)
       bussiness_days_rng =pd.date_range(start, end, freq='BM')
    

提交回复
热议问题