I need to calculate the average time between the arrival of a task and its completion. But if the task arrives on Friday, the time becomes too long due to the fact that the task is not executed on the weekend:
DT_APP_ENTERED IN_WORK
0 2023-02-17 54.80
1 2023-02-20 10.36
2 2023-02-21 10.68
3 2023-02-26 19.87
4 2023-02-27 11.35
5 2023-02-28 10.68
6 2023-03-01 10.91
7 2023-03-02 14.36
8 2023-03-03 36.46
How can I correctly add days to a datetime if weekday is friday?
I've tried to make a function:
def add_days(start_datetime):
start_datetime = month['DT_APP_ENTERED']
if start_datetime.dt.weekday == 4:
start_datetime + dt.timedelta(days=2)
else:
start_datetime
return (start_datetime)
But when I've applied it to a DF, there became an error: Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()