在python中数据仅包含HH:MM:SS时使用ARIMA模型预测时间序列数据
我有一个数据帧,它以HH:MM:SS的格式包含时间作为索引。dataframe只有一列,例如Y,其中包含浮点值。 我的数据集是:在python中数据仅包含HH:MM:SS时使用ARIMA模型预测时间序列数据,python,machine-learning,time-series,arima,Python,Machine Learning,Time Series,Arima,我有一个数据帧,它以HH:MM:SS的格式包含时间作为索引。dataframe只有一列,例如Y,其中包含浮点值。 我的数据集是: 09:37:57 121 09:39:05 73 09:40:40 91 09:40:45 101 09:47:40 69 09:52:13 81 09:58:35 83 10:00:30 428 10:
09:37:57 121
09:39:05 73
09:40:40 91
09:40:45 101
09:47:40 69
09:52:13 81
09:58:35 83
10:00:30 428
10:11:28 184
10:13:20 231
10:14:18 577
10:19:44 92
10:23:17 67
10:23:40 156
10:24:21 76
10:24:31 95
10:26:38 180
10:26:43 65
10:27:11 130
10:28:28 90
10:29:53 293
10:31:26 132
10:36:21 67
10:38:22 118
10:39:37 110
10:41:03 65
10:43:49 71
10:43:57 90
10:45:17 93
10:45:44 74
基本上,您必须理解错误消息。
首先,你有一系列的时间对象,例如
import pandas as pd
s = pd.Series(pd.datetime(2017, 5, 3, 11,11,11).time())
0 11:11:11
dtype: object
现在,让我们尝试将其转换为datetime
pd.to_datetime(s)
这将提供与您相同的错误消息
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime
(pandas\_libs\tslib.c:46617)()
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime
(pandas\_libs\tslib.c:46321)()
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime
(pandas\_libs\tslib.c:45268)()
TypeError: <class 'datetime.time'> is not convertible to datetime
pandas\\u libs\tslib.pyx在pandas中。\u libs.tslib.array\u到\u datetime
(熊猫图书馆c:46617)
熊猫\\u libs\tslib.pyx在熊猫中。_libs.tslib.array\u to\u datetime
(熊猫图书馆c:46321)
熊猫\\u libs\tslib.pyx在熊猫中。_libs.tslib.array\u to\u datetime
(熊猫图书馆c:45268)
TypeError:无法转换为datetime
因此,毫不奇怪,我们无法将时间对象转换为datetime对象,因为datepart完全缺失。基本上,您需要在此处提供一些日期。@Quickbeam2k1感谢您对错误的解释。我不时地更改了数据帧索引。它正在发挥作用。