You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/12/03 18:19:05 UTC

[GitHub] [incubator-superset] suddjian commented on a change in pull request #8724: handle nulls in bar chart series/breakdown

suddjian commented on a change in pull request #8724: handle nulls in bar chart series/breakdown
URL: https://github.com/apache/incubator-superset/pull/8724#discussion_r353343947
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -1543,10 +1544,15 @@ def query_obj(self):
     def get_data(self, df):
         fd = self.form_data
         metrics = self.metric_labels
+        columns = fd.get("columns") or []
+
+        # pandas will throw away nulls when grouping/pivoting,
+        # so we substitute NULLSTRING for any nulls in the necessary columns
+        filled_cols = self.groupby + columns
+        df[filled_cols] = df[filled_cols].fillna(value=NULLSTRING)
 
 Review comment:
   When I try `df[filled_cols].fillna(value=NULLSTRING, inplace=True)` I get this warning:
   
   > SettingWithCopyWarning:
   > A value is trying to be set on a copy of a slice from a DataFrame
   > See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org