Copilot commented on code in PR #40064:
URL: https://github.com/apache/superset/pull/40064#discussion_r3236518284


##########
superset/utils/pandas_postprocessing/histogram.py:
##########
@@ -48,8 +48,9 @@ def histogram(
     if groupby is None:
         groupby = []
 
-    # drop empty values from the target column
-    df = df.dropna(subset=[column])
+    # drop empty values from the target column;
+    # copy to avoid SettingWithCopyWarning on the to_numeric assignment below
+    df = df.dropna(subset=[column]).copy()

Review Comment:
   Calling `.copy()` here can be expensive for wide DataFrames since it 
duplicates all remaining columns, even though the goal is only to make the 
subsequent numeric-coercion assignment safe. Consider using a cheaper approach 
such as `copy(deep=False)` (shallow copy) if it still prevents the warning in 
your supported pandas versions, or restructuring to avoid copying full data 
(e.g., ensure the later assignment uses a safe pattern while minimizing data 
duplication).
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to