From 58b4956db248e5a6633fa346a9b9c7a136252d4a Mon Sep 17 00:00:00 2001 From: workpc Date: Fri, 22 Aug 2025 17:35:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=9A=E7=83=AF=E7=83=83=E6=9C=88=E5=BA=A6?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8A=A5=E5=91=8A=E6=9C=88=E5=BA=A6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA1=E6=97=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/tools.py b/lib/tools.py index 6c8264b..b3548b7 100644 --- a/lib/tools.py +++ b/lib/tools.py @@ -1114,6 +1114,12 @@ def plot_pp_predict_result(y_hat, global_config, wd='yuedu'): if wd == 'yuedu': y = pd.read_csv(os.path.join( global_config['dataset'], '指标数据.csv'))[['ds', 'y']][-12:] + print('月度历史数据日期更改') + y['ds'] = pd.to_datetime(y['ds']) + y['ds'] = y['ds'].dt.strftime('%Y-%m-01') + # ds 转换为日期类型 + y['ds'] = pd.to_datetime(y['ds']) + # 修改ds列的日为1日 print(y_hat) y_hat['ds'] = pd.to_datetime(y_hat['ds']) @@ -1155,6 +1161,9 @@ def plot_pp_predict_result(y_hat, global_config, wd='yuedu'): y_y_hat = y_y_hat.sort_values(by='ds') y = y.sort_values(by='ds') + # # y的日期转为1日 + # y['ds'] = y['ds'].dt.strftime('%Y-%m-01') + # 绘制 y_hat 的折线图,颜色为橙色 sns.lineplot(x=y_y_hat['ds'], y=y_y_hat['predictresult'], color='orange', label='预测值', ax=ax, linestyle='--', linewidth=2)