Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First Business Date of Month Python

Tags:

python

date

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')

Thanks

like image 493
user1234440 Avatar asked Dec 11 '22 15:12

user1234440


1 Answers

I think by this you can get first buisness 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)
like image 181
shivsn Avatar answered Dec 22 '22 12:12

shivsn