You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/09/05 19:36:04 UTC
[incubator-superset] 06/26: fix: pie chart multiple groupbys
(#10391)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 0.37
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 1c7022e452efa2b8824b7c73882674715aaff382
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Thu Jul 23 09:22:48 2020 +0300
fix: pie chart multiple groupbys (#10391)
---
superset/viz.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/superset/viz.py b/superset/viz.py
index 8cb2aa6..3ce9434 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1547,10 +1547,10 @@ class DistributionPieViz(NVD3Viz):
if df.empty:
return None
metric = self.metric_labels[0]
- df = df.pivot_table(index=self.groupby, values=[metric])
- df.sort_values(by=metric, ascending=False, inplace=True)
- df = df.reset_index()
- df.columns = ["x", "y"]
+ df = pd.DataFrame(
+ {"x": df[self.groupby].agg(func=", ".join, axis=1), "y": df[metric]}
+ )
+ df.sort_values(by="y", ascending=False, inplace=True)
return df.to_dict(orient="records")