I have a dataset with one input with date and time . First I wrote the code to find the first time of 5 value in X3 column and I turn that time into 0. Then I tried to add timed
In your code time= data['duration'].eq(0)
this part is making the time
variable of bool type.
Try to convert it to 0 or 1
then add it in for loop.
If time
is scalar (single) value :
if (time==True):
time=1
else:
time=0
if time
is vector (array) :
time_array = [0 if tm==False else 1 for tm in data['duration'].eq(0)]
Also, there is one more mistake in your for loop. You can't add 1
like this to data time.
Try this :
from datetime import datetime, timedelta
current_time = datetime.now()
nine_hours_from_now = current_time + timedelta(hours=9)
In this code you can replace timedelta(hours=9)
by your time timedelta(hours = time)
.
Note : your time
will be a binary array. you have to reaverse is to pick the values and add.