我有日期的数据框和列看起来像
date 1476329529 1476329530 1476329803 1476329805 1476329805 1476329805
我用它df['date'] = pd.to_datetime(df.date, format='%Y-%m-%d %H:%M:%S')来 转换,但结果很奇怪
df['date'] = pd.to_datetime(df.date, format='%Y-%m-%d %H:%M:%S')
date 1970-01-01 00:00:01.476329529 1970-01-01 00:00:01.476329530 1970-01-01 00:00:01.476329803 1970-01-01 00:00:01.476329805 1970-01-01 00:00:01.476329805 1970-01-01 00:00:01.476329805
也许我做错了
看起来是新纪元时间戳,它是1970年1月1日以来的秒数:
In [71]: pd.to_datetime(df['date'], unit='s') Out[71]: 0 2016-10-13 03:32:09 1 2016-10-13 03:32:10 2 2016-10-13 03:36:43 3 2016-10-13 03:36:45 4 2016-10-13 03:36:45 5 2016-10-13 03:36:45 Name: date, dtype: datetime64[ns]