python - Python:将时间序列应用于数据框的每一列并返回一个新行
问题描述
DATE COL1 COL2
28/10/18 10 10
29/10/18 10 10
30/10/18 10 10
我有上述格式的数据。我想使用 python 中的 ARIMA 模型预测日期 31/10/2018 的 COL1 和 COL2 的值。
有没有一种方法可以应用模型在整个数据帧上运行并将结果作为一行
DATE COL1 COL2
31/10/18 10 10
然后在末尾附加值。或者唯一可能的方法是在列中迭代并运行时间序列模型
DATE COL1 COL2
28/10/18 10 10
29/10/18 10 10
30/10/18 10 10
31/10/18 10 10
解决方案
可能的解决方案:
创建一个使用 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
推荐阅读
- passport.js - 无法使用带有nestjs的passport-outlook策略读取outlook配置文件
- flutter - 如何在 Flutter 中对齐 Card Widget 的子小部件?
- json - 使用 Angular 解析内部 json 文件中的 json 数据抛出错误
- angular - 使用单击的对象路由后路由回上一个组件
- python - 如何覆盖模型的保存方法以更改文件字段名称?
- json - 在 Serilog 中,如何在使用 {Properties} 格式说明符时从 JSON 格式的日志消息中删除空括号?
- c# - 从程序中检测服务关闭
- oracle - Count 最大连续透支天数
- substrate - 在 Substrate 中,有没有办法在另一个自定义模块中使用存储和功能?
- c# - 读取当前 Serilog 的配置