我正在尝试将一些日期时间数据转换为pandas.to_datetime()
格式。它不起作用,类型df['Time']
为Object
. 哪里错了?
请注意,我已附上我的时间文件。
我的代码
import pandas as pd
import numpy as np
from datetime import datetime
f = open('time','r')
lines = f.readlines()
t = []
for line in lines:
time = line.split()[1][-20:]
time2 = time[:11] + ' ' +time[12:21]
t.append(time2)
df = pd.DataFrame(t)
df.columns = ['Time']
df['Time'] = pd.to_datetime(df['Time'])
print df['Time']
Name: Time, Length: 16136, dtype: object
请在此处找到附加时间数据文件