I'm having trouble converting string variables into timedelta variable. According to this question: ValueError: time data 'In 00 days 23:07:56' does not match format 'In %d days %H:%M:%S'
you can solve it by changing 00 days into 01 days because date
can't be 0, but in my case, that variable is the output of time difference calculations. Is there another solution without changing my variable.
This is the code:
import datetime
import pandas as pd
df = pd.read_excel('test.xlsx')
print(df.iloc[4,1])
print(type(df.iloc[4,1]))
t = datetime.datetime.strptime((df.iloc[4,1]),"%d days %H:%M:%S")
output before the error:
0 days 00:07:02.710529
<class 'str'>
error:
File "C:\Users\khou\AppData\Local\Continuum\anaconda3\lib\_strptime.py", line 359, in _strptime
(data_string, format))
ValueError: time data '0 days 00:07:02.710529' does not match format '%d days %H:%M:%S'