首页 > 解决方案 > 在 dataframe.time 上运行自相关,包括小时和分钟

问题描述

我正在尝试autocorrelation_plot在 python 中的数据帧上运行。数据格式为:

2      07:38:30
3      06:32:30
4      07:36:30
5      06:52:30
6      06:47:00
     ...   
273    07:14:30
274    08:47:30
280    08:37:00
281    09:21:30
284    08:10:30
Name: endTime, Length: 199, dtype: object

我只能通过使用 .hour 转换才能在小时内运行它:

df_valid.endTime = pd.to_datetime(df_valid.endTime, format='%Y-%m-%dT%H:%M:%S').dt.hour
fig, ax = plt.subplots(figsize=(20, 10))
autocorrelation_plot(df_valid.endTime, ax=ax)

但我也想包括会议记录,以便更准确。但是,当我尝试不先进行 .hour 转换时,我得到了TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.time'

关于为什么的任何想法?

标签: pythonpandasdataframe

解决方案


推荐阅读