eschutho commented on code in PR #29898:
URL: https://github.com/apache/superset/pull/29898#discussion_r1769254370


##########
superset/charts/post_processing.py:
##########
@@ -151,6 +153,18 @@ def pivot_df(  # pylint: disable=too-many-locals, 
too-many-arguments, too-many-s
         # add subtotal for each group and overall total; we start from the
         # overall group, and iterate deeper into subgroups
         groups = df.columns
+        if not apply_metrics_on_rows:
+            for col in df.columns:
+                # we need to replace the temporary placeholder with either a 
string
+                # or np.nan, depending on the column type so that they can sum 
correctly
+                if pd.api.types.is_numeric_dtype(df[col]):
+                    df[col].replace("SUPERSET_PANDAS_NAN", np.nan, 
inplace=True)
+                else:
+                    df[col].replace("SUPERSET_PANDAS_NAN", "nan", inplace=True)

Review Comment:
   I chose the string "nan" here because that is the default behavior when 
there is a null value when pivoting without sums.



-- 
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