简体   繁体   中英

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

I have data in above format. I want to predict the value of COL1 and COL2 for date 31/10/2018 using the ARIMA model in python.

Is there a way I can apply the model to run on whole data frame and get the result as a row

DATE COL1 COL2
31/10/18 10 10

and then append the value at the end. Or the only way possible is going iteratively in the columns and running the time series model

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

Possible solution:

create a function that uses the ARIMA model and return only the data you want.

There are two ways:

#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)

having the results, you can already organize data learn more https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM