Skip to content

Commit

Permalink
fix: pie chart multiple groupbys (#10391)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Sep 5, 2020
1 parent 003161e commit 1c7022e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,10 +1547,10 @@ def get_data(self, df: pd.DataFrame) -> VizData:
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")


Expand Down

0 comments on commit 1c7022e

Please sign in to comment.