I stored multiple DataFrames in a dictionary,
df_dict = {product: product_df.drop(['productID', 'productName'],axis = 1).sort(['date'])
for product, product_df in products}
The dictionary looks like this,
Key Type Size Values
1 DataFrame (100,2) Column names: date, sales
2 DataFrame (130,2) Column names: date, sales
3 DataFrame (115,2) Column names: date, sales
4 DataFrame (137,2) Column names: date, sales
I would like to write a for loop to store each DataFrame forecasting results in a list or a dictionary. This is how I did it, the value in the dictionary is DataFrames
and the key is productID
a = []
for key, value in df_dict:
m = Prophet()
m.fit(value)
future = m.make_future_dataframe(periods = 365)
forecast = m.predict(future)
a.append(forecast)
However, in the list a = []
, the index is reset rather than the keys in a dictionary. Is there any ways to store the results with keys as reference index?