[英]ValueError: time data '00:01:29:06' does not match format '%d:%H:%M:%S'
The reason of the error is that the %d
format only accepts values between 01
and 31
(since it stands for "day of the month").错误的原因是
%d
格式只接受01
和31
之间的值(因为它代表“一个月中的某一天”)。 00
is then not valid. 00
则无效。
The best workaround I could figure (someone might suggest something better) is to use regular expression to convert the strings contained in the duration
column into some valid string as in the following example:我能想到的最佳解决方法(有人可能会提出更好的建议)是使用正则表达式将
duration
列中包含的字符串转换为一些有效字符串,如下例所示:
df['duration']=pd.to_timedelta(df.duration.str.replace(r"(?P<day>\d+):", r'\g<day> days ', 1))
I've no idea about the time complexity of the above example (in case of have a big table to convert).我不知道上面例子的时间复杂度(如果有一个大表要转换)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.