mirror of https://github.com/apache/superset.git
fix(utils): fix off-by-one error in how rolling window's min_periods truncates dataframe (#27388)
This commit is contained in:
parent
bfe55b9ded
commit
d4d8625ab8
|
@ -97,5 +97,5 @@ def rolling( # pylint: disable=too-many-arguments
|
|||
df_rolling = _append_columns(df, df_rolling, columns)
|
||||
|
||||
if min_periods:
|
||||
df_rolling = df_rolling[min_periods:]
|
||||
df_rolling = df_rolling[min_periods - 1 :]
|
||||
return df_rolling
|
||||
|
|
|
@ -107,7 +107,7 @@ def test_rolling():
|
|||
)
|
||||
|
||||
|
||||
def test_rolling_should_empty_df():
|
||||
def test_rolling_min_periods_trims_correctly():
|
||||
pivot_df = pp.pivot(
|
||||
df=single_metric_df,
|
||||
index=["dttm"],
|
||||
|
@ -121,7 +121,7 @@ def test_rolling_should_empty_df():
|
|||
min_periods=2,
|
||||
columns={"sum_metric": "sum_metric"},
|
||||
)
|
||||
assert rolling_df.empty is True
|
||||
assert len(rolling_df) == 1
|
||||
|
||||
|
||||
def test_rolling_after_pivot_with_single_metric():
|
||||
|
|
Loading…
Reference in New Issue