I want to change start end time in CustomBusinessHour if i get monday in weekmask list from startdate and enddate . start = 00:01 end = 23:59
i am trying to change this start to 07:00 and end =23:59 if i get monday b/w startdate and enddate
data = {
'start': ['2018-10-29 18:48:46.697000',
'2018-10-29 19:01:10.887000',
'2018-10-22 17:42:24.467000'],
'end': ['2018-10-31 17:56:38.830000',
'2018-11-27 09:31:39.967000',
'2018-11-28 18:33:35.243000' ]
}
df = pd.DataFrame(data)
bh = CustomBusinessHour(calendar=USFederalHolidayCalendar(),start='00:01', end='23:59')
df['Hours_diff'] = df.apply(lambda x: len(pd.date_range(start=x.start, end=x.end, freq= bh)),axis=1)
You could use
apply
with a function, to feed the start and enddatetime
for each row. Then you use a mask on top of yourCustomBusinessHour
.Gives
Make sure that's correct, I haven't checked.