You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/06/13 23:31:47 UTC

(superset) branch master updated: fix(pandas-postprocessing): resolve SettingWithCopyWarning in histogram and boxplot (#36605)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 02f32469b05 fix(pandas-postprocessing): resolve SettingWithCopyWarning in histogram and boxplot (#36605)
02f32469b05 is described below

commit 02f32469b050d75f3449a9272d65844fa2a7a81c
Author: Nitish Agarwal <15...@users.noreply.github.com>
AuthorDate: Sun Jun 14 05:01:32 2026 +0530

    fix(pandas-postprocessing): resolve SettingWithCopyWarning in histogram and boxplot (#36605)
    
    Co-authored-by: Evan Rusackas <ev...@preset.io>
---
 superset/utils/pandas_postprocessing/boxplot.py   | 5 +++--
 superset/utils/pandas_postprocessing/histogram.py | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/superset/utils/pandas_postprocessing/boxplot.py b/superset/utils/pandas_postprocessing/boxplot.py
index eb93b20844e..3722dedf5c7 100644
--- a/superset/utils/pandas_postprocessing/boxplot.py
+++ b/superset/utils/pandas_postprocessing/boxplot.py
@@ -19,6 +19,7 @@ from typing import Any, Callable, Optional, Union
 import numpy as np
 from flask_babel import gettext as _
 from pandas import DataFrame, Series, to_numeric
+from pandas.api.types import is_object_dtype
 
 from superset.exceptions import InvalidPostProcessingError
 from superset.utils.core import PostProcessingBoxplotWhiskerType
@@ -126,7 +127,7 @@ def boxplot(  # noqa: C901
     # nanpercentile needs numeric values, otherwise the isnan function
     # that's used in the underlying function will fail
     for column in metrics:
-        if df.dtypes[column] == np.object_:
-            df[column] = to_numeric(df[column], errors="coerce")
+        if is_object_dtype(df[column]):
+            df.loc[:, column] = to_numeric(df[column], errors="coerce")
 
     return aggregate(df, groupby=groupby, aggregates=aggregates)
diff --git a/superset/utils/pandas_postprocessing/histogram.py b/superset/utils/pandas_postprocessing/histogram.py
index d274d5359df..835448115bb 100644
--- a/superset/utils/pandas_postprocessing/histogram.py
+++ b/superset/utils/pandas_postprocessing/histogram.py
@@ -54,7 +54,7 @@ def histogram(
         return df
 
     # convert to numeric, coercing errors to NaN
-    df[column] = to_numeric(df[column], errors="coerce")
+    df.loc[:, column] = to_numeric(df[column], errors="coerce")
 
     # check if the column contains non-numeric values
     if df[column].isna().any():