Reputation: 306
I am trying to create a date range using pd.date_range
from 2018-01-01
to 2018-01-31
for days of the week Monday, Tuesday, Wednesday
, from 6 AM - 6 PM
at every 12 minutes
.
Basically, I need an array of datetime objects or strings with a value every 12 minutes for particular days of the week, between particular business hours for the given range of dates. I am not able to use CustomBusinessDay
, CustomBusinessHour
and freq
together to get the desired range of datetime objects.
Any suggestions?
Upvotes: 1
Views: 2600
Reputation: 18201
You could use
index = pd.date_range('2018-01-01', '2018-02-01', freq='12min')
index[(index.dayofweek <= 2) & (index.hour >= 6) & (index.hour < 18)]
Upvotes: 4