mistercrunch commented on a change in pull request #5026: Fix percent_metrics 
ZeroDivisionError
URL: 
https://github.com/apache/incubator-superset/pull/5026#discussion_r189023674
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -581,7 +584,8 @@ def get_data(self, df):
                 for m in percent_metrics
             }
             metric_percents = {
-                m: list(map(lambda a: a / metric_sums[m], df[m]))
+                m: list(map(
+                    lambda a: a / (1 if metric_sums[m] == 0 else 
metric_sums[m]), df[m]))
 
 Review comment:
   Shouldn't we just go with `None` if there's a division by 0?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to