eschutho commented on code in PR #29898:
URL: https://github.com/apache/superset/pull/29898#discussion_r1769247070
##########
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)
+ else:
+ # when we applied metrics on rows, we switched the columns and rows
+ # so checking column type doesn't apply. Replace everything with
np.nan
+ df.replace("SUPERSET_PANDAS_NAN", np.nan, inplace=True)
Review Comment:
@betodealmeida we need this section here (from line 156) when totaling so
that we 1) can sum with numbers (by converting the string "SUPERSET_PANDAS_NAN"
with np.nan or 2) can sum with a string value. I'm using "nan" so that we don't
print "SUPERSET_PANDAS_NAN".
--
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]