In my script I get two huge np arrays that I want to subtract. The first numpy array start_per_day with the times the working day started and a second numpy array end_per_day.
However I get the below error. Couldn't figure it out, appreciate any help.
Edit: below is a minimal reproducible example where the arrays are artificially were created by me
Edit2: Since I was asked multiple Times about the origina of my two datetime.time numpy arrays, I extract them from pandas groupby with min and max see code below
print(one_employe)
start_per_day = one_employe.groupby('Date')['Time'].min()
end_per_day = one_employe.groupby('Date')['Time'].max()
print(end_per_day.values)
print(start_per_day.values)
The output of the 3 print commands
ID Datetime Date Time 0 13 2020-03-02 09:43:00 2020-03-02 09:43:00 3 13 2020-03-02 18:22:00 2020-03-02 18:22:00 5 13 2020-03-03 09:51:00 2020-03-03 09:51:00 8 13 2020-03-03 18:28:00 2020-03-03 18:28:00 [datetime.time(18, 22) datetime.time(18, 28)] [datetime.time(9, 43) datetime.time(9, 51)]
Original Post - Code:
import datetime
import numpy as np
start_per_day = np.array([datetime.time(9, 43),datetime.time(9, 51)])
end_per_day = np.array([datetime.time(18,22),datetime.time(18,29)])
#Attemps that didnt work:
np.datetime64(end_per_day) - np.datetime64(start_per_day)
datetime.timedelta( end_per_day, start_per_day)
end_per_day - start_per_day
Error:
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'