mirror of
https://github.com/apache/superset.git
synced 2026-05-11 19:05:24 +00:00
fix(post-processing): handle missing values in cumulative operator (#26429)
(cherry picked from commit ff025b78f3)
This commit is contained in:
committed by
Michael S. Molina
parent
2a30d59b05
commit
439979c73a
@@ -24,6 +24,7 @@ from tests.unit_tests.fixtures.dataframes import (
|
||||
multiple_metrics_df,
|
||||
single_metric_df,
|
||||
timeseries_df,
|
||||
timeseries_with_gap_df,
|
||||
)
|
||||
from tests.unit_tests.pandas_postprocessing.utils import series_to_list
|
||||
|
||||
@@ -77,6 +78,19 @@ def test_cum():
|
||||
)
|
||||
|
||||
|
||||
def test_cum_with_gap():
|
||||
# create new column (cumsum)
|
||||
post_df = pp.cum(
|
||||
df=timeseries_with_gap_df,
|
||||
columns={"y": "y2"},
|
||||
operator="sum",
|
||||
)
|
||||
assert post_df.columns.tolist() == ["label", "y", "y2"]
|
||||
assert series_to_list(post_df["label"]) == ["x", "y", "z", "q"]
|
||||
assert series_to_list(post_df["y"]) == [1.0, 2.0, None, 4.0]
|
||||
assert series_to_list(post_df["y2"]) == [1.0, 3.0, 3.0, 7.0]
|
||||
|
||||
|
||||
def test_cum_after_pivot_with_single_metric():
|
||||
pivot_df = pp.pivot(
|
||||
df=single_metric_df,
|
||||
|
||||
Reference in New Issue
Block a user