1
My hourly data set is stored in the time = [0 variable. , 0.08333333, 0.16666667, 0.25, 0.333333, 0.41666667, 0.5 , 0.58333333, 0.666667, 0.75, 0.83333333, 0.91666667, 1. , 08333333, 1.16666667]
Can anyone tell me if there is a simple way to convert this into hh:mm:ss format?
I tried to create a function, but this giving error:
import datetime as dt
from datetime import timedelta
def time2dt(time):
seconds = int(time*60*60)
minutes, seconds = int(divmod(seconds, 60))
hours, minutes = int(divmod(minutes, 60))
return dt.datetime(hours, minutes, seconds) + dt.timedelta(time % 1)
dates = [time2dt(time[i]) for i in np.arange(len(time))]
datestr = [i.strftime('%H:%M:%S') for i in dates]
Typeerror: int() argument must be a string or a number, not 'tuple'
Doing this, another error appears: Attributeerror: type Object 'datetime.time' has no attribute 'time'
– Luana