fix(pandas-postprocessing): percentage compare to use correct column (#16716)

This commit is contained in:
Ville Brofeldt 2021-09-16 13:29:58 +03:00 committed by GitHub
parent 836b5e2c86
commit a839649e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -508,7 +508,7 @@ def compare( # pylint: disable=too-many-arguments
diff_series = df[s_col] - df[c_col]
elif compare_type == PandasPostprocessingCompare.PCT:
diff_series = (
((df[s_col] - df[c_col]) / df[s_col]).astype(float).round(precision)
((df[s_col] - df[c_col]) / df[c_col]).astype(float).round(precision)
)
else:
# compare_type == "ratio"

View File

@ -513,7 +513,7 @@ class TestPostProcessing(SupersetTestCase):
post_df.columns.tolist(), ["label", "y", "z", "percentage__y__z",]
)
self.assertListEqual(
series_to_list(post_df["percentage__y__z"]), [0.0, -1.0, -4.0, -3],
series_to_list(post_df["percentage__y__z"]), [0.0, -0.5, -0.8, -0.75],
)
# `ratio` comparison