From 0782e831cd37f665a2838119d87c433269f1b36b Mon Sep 17 00:00:00 2001 From: Conglei Date: Thu, 14 Mar 2019 14:05:06 -0700 Subject: [PATCH] fix inaccurate data calculation with adata rolling and contribution (#7035) --- superset/viz.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/superset/viz.py b/superset/viz.py index de33a3ca8c8b3..ef7ee456ebe11 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -1184,10 +1184,6 @@ def process_data(self, df, aggregate=False): dfs.sort_values(ascending=False, inplace=True) df = df[dfs.index] - if fd.get('contribution'): - dft = df.T - df = (dft / dft.sum()).T - rolling_type = fd.get('rolling_type') rolling_periods = int(fd.get('rolling_periods') or 0) min_periods = int(fd.get('min_periods') or 0) @@ -1207,6 +1203,10 @@ def process_data(self, df, aggregate=False): if min_periods: df = df[min_periods:] + if fd.get('contribution'): + dft = df.T + df = (dft / dft.sum()).T + return df def run_extra_queries(self):