This is the dataframe I have. I am trying to associate number of hours spent on a project per week with the corresponding weekstart and weekend time frame.
Entry Exit
2019-07-01 09:56:00 2020-06-29 11:54:00
2019-07-13 07:43:00 2020-06-26 15:38:00
2019-07-18 13:59:00 2020-06-24 11:57:00
I have used this function to find weekstart and weekend:
def find_week_start(date):
if date.weekday() == 6:
return date
else:
week_start = (date- datetime.timedelta(days = date.weekday() + 1))
return week_start
#function to find last day of week (Saturday)
def find_week_end(date):
week_end = find_week_start(date) + datetime.timedelta(days = 6)
return week_end
But I need the hours to associate with the weeks in between the two periods as well.
It Needs to look something like this (using the first row of the data listed above as an example).
WeekStart WeekEnd Hours
2019-06-30 00:00:00 2019-07-06 23:59:59 134.066
2019-07-07 00:00:00 2019-07-13 23:59:59 168
2019-07-14 00:00:00 2019-07-20 23:59:59 168
...
...
...
...
2020-06-28 00:00:00 2020-07-04 23:59:59 35.9
Eventually this will turn into a groupby function by WeekStart and WeekEnd, summing the total hour for each week.