Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): fix off-by-one error in how rolling window's min_periods truncates dataframe #27388

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset/utils/pandas_postprocessing/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/unit_tests/pandas_postprocessing/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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():
Expand Down
Loading