I have a dataframe with columns "Created Date" and "Closed Date". I'm hoping generate a column of elapsed time in business hours between the two columns of dates. I can use businesstimedelta to do this, but it seems to only work with pairs of single entries. I thus have,
workday = businesstimedelta.WorkDayRule(
start_time=datetime.time(8),
end_time=datetime.time(20),
working_days=[0, 1, 2, 3, 4])
businesshrs=businesstimedelta.Rules([workday])
to define the intervals of time that count toward business hours, and
for i in range(0,len(df)):
df['TTR'][i]=businesshrs.difference(df['Created Date'][i],df['Closed Date'][i]).hours+float(businesshrs.difference(df['Created Date'][i],df['Closed Date'][i]).seconds)/float(3600)
to loop over each row and calculate the time difference. This works, but is abysmally slow. If I simply try to call each column in the "businesshrs.difference" arguments, I get a type-error.
Does anyone know of a good way to accomplish what I'm trying to do? Thanks!