mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
fix(pandas-postprocessing): percentage compare to use correct column (#16716)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user