Skip to content

Commit

Permalink
test: Add test for rolling stability sort (pola-rs#21456)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored and anath2 committed Mar 5, 2025
1 parent 3fdeab4 commit 291a682
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions py-polars/tests/unit/operations/rolling/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,3 +1351,42 @@ def test_rolling_sum_stability_11146() -> None:
)["test_col"][-1]
== 0.0
)


def test_rolling() -> None:
df = pl.DataFrame(
{
"n": [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],
"col1": ["A", "B"] * 11,
}
)

assert df.rolling("n", period="1i", group_by="col1").agg().to_dict(
as_series=False
) == {
"col1": [
"A",
"A",
"A",
"A",
"A",
"A",
"A",
"A",
"A",
"A",
"A",
"B",
"B",
"B",
"B",
"B",
"B",
"B",
"B",
"B",
"B",
"B",
],
"n": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
}

0 comments on commit 291a682

Please sign in to comment.