[英]Pandas to_datetime returns error for perfectly fine python time
So I have a bunch of data that has timestamps in python epoch time format, however using this to_datetime() function returns ValueError: unconverted data remains: 00
因此,我有一堆具有python epoch时间格式的时间戳的数据,但是使用此to_datetime()函数将返回
ValueError: unconverted data remains: 00
Here's the code 这是代码
import pandas as pd
print pd.to_datetime('1451080800', format='%Y%m%d')
What's going wrong here ? 这是怎么了?
Since you say it is epoch time, I think you want this: 既然您说现在是时代,我想您想要这样:
In [44]: pd.to_datetime(int('1451080800'), unit='s')
Out[44]: Timestamp('2015-12-25 22:00:00')
Note the int(..)
around the string. 注意字符串周围的
int(..)
。 When specifying a unit
(epoch is in seconds since 1970), the argument needs to be an integer. 指定
unit
(自1970年以来的秒数)时,参数必须为整数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.