So I have several csv files that I am importing in and then I use FB Prophet to give me a forecast for the coming months data. I would like all of the forecasts to go to either a different csv or all on the same one. Currently it is only writing the last csv of filenames to a csv and not doing the others.
filenames=['example1.csv','example2.csv','example3.csv']
for f in filenames:
df=pd.read_csv(f)
df.columns=['ds','y']
df['ds']=pd.to_datetime(df['ds'])
m=Prophet(seasonality_mode='multiplicative')
m.fit(df)
future=m.make_future_dataframe(periods=6,freq='M')
forecast=m.predict(future)
forecast[['ds','yhat','yhat_lower','yhat_upper']].tail()
fig1=m.plot(forecast)
fig2=m.plot_components(forecast)
forecast.to_csv(f)
I expect all of the forecasts to be on one csv or have a new csv created for each filename that is looped through.