0

I am looking for guidance on how to create a variable (Business_Time) which contains only business days (not weekends) and where i can set working hours (9am - 6pm GMT).

The reason for this is because i'm trying to calculate some SLA's (how long employees have to complete a task), however if the end time falls outside of these business days/hours, then i can set it to a specific time.

Many thanks

1 Answers1

0

pandas already implement BusinessHour and BusinessDay:

from pandas.tseries.offsets import BusinessDay
from pandas.tseries.offsets import BusinessHour
from dateutil import parser

myDate = parser.parse('Fri, 7 Jan 2022 17:00:00 +0000 (UTC)')
myWorkTime = BusinessDay(1) + BusinessHour(1)

print(myDate + myWorkTime)

This will print Timestamp('2022-01-11 10:00:00+0000', tz='tzutc()').

You can find a lot of tutorials over the internet (like this one for example)

WildSiphon
  • 110
  • 1
  • 6