Python:将时间序列应用于数据帧的每一列并返回n

2024-04-26 21:09:35 发布

您现在位置:Python中文网/ 问答频道 /正文

DATE COL1 COL2
28/10/18 10 10
29/10/18 10 10
30/10/18 10 10

我有以上格式的数据。我想使用python中的ARIMA模型预测2018年10月31日COL1和COL2的值。在

有没有一种方法可以应用这个模型在整个数据帧上运行并得到一行的结果

^{pr2}$

然后在末尾附加值。或者唯一可能的方法是在列中迭代并运行时间序列模型

DATE COL1 COL2
28/10/18 10 10
29/10/18 10 10
30/10/18 10 10
31/10/18 10 10

Tags: 数据方法模型date格式时间序列col2
1条回答
网友
1楼 · 发布于 2024-04-26 21:09:35

可能的解决方案:

创建一个使用ARIMA模型并只返回所需数据的函数。在

有两种方法:

#applies to the entire data frame (0 = index and 1 = columns)
df2 = df.apply(function, axis=1)

#applies only to the series
df2 = df['date'].apply(function)

有了结果,你就可以组织数据了 了解更多https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html

相关问题 更多 >