diff --git a/superset/viz.py b/superset/viz.py index f4890ec69b043..e7763ba6bfbf6 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -625,17 +625,18 @@ def get_data(self, df: pd.DataFrame) -> VizData: self.form_data.get("percent_metrics") or [] ) - df = pd.concat( - [ - df[non_percent_metric_columns], - ( - df[percent_metric_columns] - .div(df[percent_metric_columns].sum()) - .add_prefix("%") - ), - ], - axis=1, - ) + if not df.empty: + df = pd.concat( + [ + df[non_percent_metric_columns], + ( + df[percent_metric_columns] + .div(df[percent_metric_columns].sum()) + .add_prefix("%") + ), + ], + axis=1, + ) data = self.handle_js_int_overflow( dict(records=df.to_dict(orient="records"), columns=list(df.columns))