From 5609a8d70880ed11129bd9e8bae0d6a19670ff2e Mon Sep 17 00:00:00 2001 From: DXC Date: Fri, 10 Jul 2026 14:49:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(pre=5Fprocessing.py):=20=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=80=BC=E6=A3=80=E6=B5=8B=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove_outliers() 函数: - 原代码: fig = None # plotting disabled - 修复: 调用 plotting.outliers(df, column, name) 生成箱线图, 显示 IQR 方法的异常值检测结果 异常保护:try/except 包裹,绘图失败时回退至 None --- src/gasflux/pre_processing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gasflux/pre_processing.py b/src/gasflux/pre_processing.py index 1502748..abe35e9 100644 --- a/src/gasflux/pre_processing.py +++ b/src/gasflux/pre_processing.py @@ -129,7 +129,11 @@ def remove_outliers(df: pd.DataFrame, column: str, name: str): fence_low = q1 - 3 * iqr fence_high = q3 + 3 * iqr - fig = None # plotting disabled + try: + from . import plotting + fig = plotting.outliers(df, column, name) + except Exception: + fig = None outliers = df.loc[(df[column] < fence_low) | (df[column] > fence_high)] if len(outliers) > 0: