我想将以下日期和时间列合并为1个日期和时间列:
casinghourly[['Date','Time']].head()
Out[275]:
Date Time
0 2014-01-01 00:00:00
1 2014-01-01 01:00:00
2 2014-01-01 02:00:00
3 2014-01-01 03:00:00
4 2014-01-01 04:00:00
我使用了以下代码:
casinghourly.loc[:,'Date_Time'] = pd.to_datetime(casinghourly.Date.astype(str)+' '+casinghourly.Time.astype(str))
但我得到了以下错误:
ValueError: Unknown string format
供参考:
casinghourly[['Date','Time']].dtypes
Out[276]:
Date datetime64[ns]
Time timedelta64[ns]
dtype: object
有人能帮我吗
您可以直接使用
timedelta64[ns]
连接datetime64[ns]
:相关问题 更多 >
编程相关推荐