Adding column headers name in streamlit for time series forecasting

I am trying to pull column names using st.multiselect widget in model.add_regressor prophet for time series forecasting. I am able to pull only 1 column and need to knoe how to pull selected column?

Hi there,

Thanks for sharing your question with the community! Check out our guidelines on how to post an effective question here – in particular, please share a code snippet so we can reproduce the issue.

Here is the piece of my code…

Add regressors

columns=st.multiselect("Select regressor variables columns",df.columns.unique())
model_new = Prophet() #instantiate Prophet
for k in columns: 
future_data = model_new.make_future_dataframe(periods= dur,freq = freq)

df=df.append(df_test)"This is future_data for forecast")
# Forecast Button

if st.button(“Forecast”):
with st.spinner(text=‘Prophet is forecasting…’):
forecast_data = model_new.predict(future_data)
st.write(forecast_data[[‘ds’, ‘yhat’, ‘yhat_lower’, ‘yhat_upper’]].tail(5))

Here is the output in streamlit

I want to ask, when I select 3 regressors, the future dataframe takes only one as a result, it raises value error while predicting?
How to get rid of this, could you please help?
Thanks a lot.

You have k here when it looks like it was instantiated for iteration in the loop above. You need to make a list that includes ‘ds’ and all the entries in columns from the multiselect.

result_cols = ['ds'] + columns
1 Like

Thanks a lot!
This really works for me.
Now future dataframe is taking all parameters for forecast.
Thanks once again.