Search code examples
pythondate

First Business Date of Month Python


How do I determine the first business date of the month in python? the program I am writing is drip fed dates each loop and I need to be able to get a true/false.

I found that you can get last working business day with:

import pandas as pd
pd.date_range("2014-01-14", periods=1, freq='BM')

Solution

  • I think by this you can get first business date of the month using BMS:

     In[82]: pd.date_range('1/1/2000', '12/1/2000', freq='BMS')
    Out[82]: 
    DatetimeIndex(['2000-01-03', '2000-02-01', '2000-03-01', '2000-04-03',
                   '2000-05-01', '2000-06-01', '2000-07-03', '2000-08-01',
                   '2000-09-01', '2000-10-02', '2000-11-01', '2000-12-01'],
                  dtype='datetime64[ns]', freq='BMS', tz=None)