Why is the timedelta command generating an error on another computer?
I am currently working on two different computers, but one of the computers is running the same code on one of the two computers:
ValueError: cannot create timedelta string converter for [-1 days +23:05:00.000000000]
The error was caused by the command:
df_gt["Duration"] = pd.to_timedelta(df_gt[ "Duration"])
And df is created by importing csv via:
df_gt = pd.read_csv(gt_data, sep='\t', header=(0))
First, I thought the error was caused by a negative number. I've seen problems with negative numbers in the past, but it must have been the same problem on a different computer.
Then I wondered if this could be caused by another csv / time setting on this computer generating other formats, but when I print the value, I get exactly the same format (at least by visual inspection). I still think the problem is somewhere in this domain, but I'm not sure how another computer might affect this internal code.
Some information about the hardware:
The computer that everything runs on is running Windows 10 Home and is using Pycharm Professional 2017.1. The other is running Windows 7 Professional sp 1 and is using Spyder 2.3.1. The code is in Python 3.
Thanks in advance,
Jeff
EDIT:
The original question still had
.total_seconds()
attached to the team, it was by mistake. (Just an attempt by my self to resolve this)
source to share
You may need .dt
:
df_gt["Duration"] = pd.to_timedelta(df_gt[ "Duration"]).dt.total_seconds()
There seem to be different versions of pandas, so the oldest version doesn't work.
The version 0.14.1
was released on July 11, 2014 .
The version 0.20.1
was released on May 5, 2017 .
source to share