[英]Find for a word in a each row of dataframe column and add a new column - Python
[英]Python: Apply Time series to each column of a dataframe and return a new row
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/generation/pandas.DataFrame.apply.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.