我很新于使用Python和Prophet进行时间序列分析。我的数据集包含文章代码、日期和销售数量等变量。我尝试使用Prophet在Python中为每篇文章的每个月预测销售数量,但我不知道如何在输出(预测)数据中显示文章类型,并直接从“for循环”将其写入文件。。
我希望输出结果如下,并希望直接从“for循环”将其写入输出文件。
df2 = df2.rename(columns={'Date of the document': 'ds','Quantity sold': 'y'})
for article in df2['Article bar code']:
# set the uncertainty interval to 95% (the Prophet default is 80%)
my_model = Prophet(weekly_seasonality= True, daily_seasonality=True,seasonality_prior_scale=1.0)
my_model.fit(df2)
future_dates = my_model.make_future_dataframe(periods=6, freq='MS')
forecast = my_model.predict(future_dates)
return forecast
我希望输出结果如下,并希望直接从“for循环”将其写入输出文件。
提前致谢。
df = df.rename(columns={'Date of the document': 'ds','Quantity sold': 'y', 'Article bar code': 'article'})
应该改为:df2 = df.rename(columns={'Date of the document': 'ds','Quantity sold': 'y', 'Article bar code': 'article'})
,对吗? - Mysterio