diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 0f32b704deff..6988322dd67d 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -2047,7 +2047,7 @@ def test_shift_and_fill() -> None: "ham": ["a", "b", "c"], } ) - result = df.shift_and_fill(fill_value=0, periods=1) + result = df.shift_and_fill(fill_value=0, n=1) expected = pl.DataFrame( { "foo": [0, 1, 2], diff --git a/py-polars/tests/unit/datatypes/test_categorical.py b/py-polars/tests/unit/datatypes/test_categorical.py index be707cb207a4..cd906a46c6a5 100644 --- a/py-polars/tests/unit/datatypes/test_categorical.py +++ b/py-polars/tests/unit/datatypes/test_categorical.py @@ -146,7 +146,7 @@ def test_shift_and_fill() -> None: [pl.col("a").cast(pl.Categorical)] ) - s = df.with_columns(pl.col("a").shift_and_fill("c", periods=1))["a"] + s = df.with_columns(pl.col("a").shift_and_fill("c", n=1))["a"] assert s.dtype == pl.Categorical assert s.to_list() == ["c", "a"] diff --git a/py-polars/tests/unit/datatypes/test_temporal.py b/py-polars/tests/unit/datatypes/test_temporal.py index aa79cfa82c3e..4b4a50e9b3cd 100644 --- a/py-polars/tests/unit/datatypes/test_temporal.py +++ b/py-polars/tests/unit/datatypes/test_temporal.py @@ -1421,7 +1421,7 @@ def test_supertype_timezones_4174() -> None: # test if this runs without error date_to_fill = df["dt_London"][0] - df.with_columns(df["dt_London"].shift_and_fill(date_to_fill, periods=1)) + df.with_columns(df["dt_London"].shift_and_fill(date_to_fill, n=1)) @pytest.mark.skip(reason="from_dicts cannot yet infer timezones") @@ -1446,7 +1446,7 @@ def test_shift_and_fill_group_logicals() -> None: schema=["d", "s"], ) assert df.select( - pl.col("d").shift_and_fill(pl.col("d").max(), periods=-1).over("s") + pl.col("d").shift_and_fill(pl.col("d").max(), n=-1).over("s") ).dtypes == [pl.Date] diff --git a/py-polars/tests/unit/operations/map/test_map_batches.py b/py-polars/tests/unit/operations/map/test_map_batches.py index 27cadd5a36e1..4f824dfc9951 100644 --- a/py-polars/tests/unit/operations/map/test_map_batches.py +++ b/py-polars/tests/unit/operations/map/test_map_batches.py @@ -22,7 +22,7 @@ def test_map_no_dtype_set_8531() -> None: df = pl.DataFrame({"a": [1]}) result = df.with_columns( - pl.col("a").map_batches(lambda x: x * 2).shift_and_fill(fill_value=0, periods=0) + pl.col("a").map_batches(lambda x: x * 2).shift_and_fill(fill_value=0, n=0) ) expected = pl.DataFrame({"a": [2]}) diff --git a/py-polars/tests/unit/operations/rolling/test_rolling.py b/py-polars/tests/unit/operations/rolling/test_rolling.py index 0f763f1a04c2..1cfd275a0c6a 100644 --- a/py-polars/tests/unit/operations/rolling/test_rolling.py +++ b/py-polars/tests/unit/operations/rolling/test_rolling.py @@ -386,7 +386,7 @@ def test_rolling_slice_pushdown() -> None: ) .agg( [ - (pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, periods=1)) + (pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, n=1)) .sum() .alias("c") ] diff --git a/py-polars/tests/unit/operations/test_group_by_dynamic.py b/py-polars/tests/unit/operations/test_group_by_dynamic.py index 3862901e5a7b..a1c2cc3b06f2 100644 --- a/py-polars/tests/unit/operations/test_group_by_dynamic.py +++ b/py-polars/tests/unit/operations/test_group_by_dynamic.py @@ -320,7 +320,7 @@ def test_group_by_dynamic_slice_pushdown() -> None: df.sort("a") .group_by_dynamic("a", by="b", every="2i") .agg( - (pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, periods=1)) + (pl.col("c") - pl.col("c").shift_and_fill(fill_value=0, n=1)) .sum() .alias("c") ) diff --git a/py-polars/tests/unit/operations/test_window.py b/py-polars/tests/unit/operations/test_window.py index 5e00bd9c947d..f06d87a3b528 100644 --- a/py-polars/tests/unit/operations/test_window.py +++ b/py-polars/tests/unit/operations/test_window.py @@ -243,15 +243,11 @@ def test_window_functions_list_types() -> None: # as it is the same as shift. # that's why we don't add it to the allowed types. assert ( - df.select( - pl.col("col_list").shift_and_fill(None, periods=1).alias("list_shifted") - ) + df.select(pl.col("col_list").shift_and_fill(None, n=1).alias("list_shifted")) )["list_shifted"].to_list() == [None, [1], [1], [2]] assert ( - df.select( - pl.col("col_list").shift_and_fill([], periods=1).alias("list_shifted") - ) + df.select(pl.col("col_list").shift_and_fill([], n=1).alias("list_shifted")) )["list_shifted"].to_list() == [[], [1], [1], [2]] diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index c77cb2cecb5b..0eb1bca930a9 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -1085,7 +1085,7 @@ def test_shift() -> None: assert_series_equal(a.shift(1), pl.Series("a", [None, 1, 2])) assert_series_equal(a.shift(-1), pl.Series("a", [2, 3, None])) assert_series_equal(a.shift(-2), pl.Series("a", [3, None, None])) - assert_series_equal(a.shift_and_fill(10, periods=-1), pl.Series("a", [2, 3, 10])) + assert_series_equal(a.shift_and_fill(10, n=-1), pl.Series("a", [2, 3, 10])) def test_object() -> None: diff --git a/py-polars/tests/unit/test_lazy.py b/py-polars/tests/unit/test_lazy.py index 7fe0dae5f371..39ed3a3faed9 100644 --- a/py-polars/tests/unit/test_lazy.py +++ b/py-polars/tests/unit/test_lazy.py @@ -289,12 +289,12 @@ def test_shift_and_fill() -> None: # use exprs out = ldf.with_columns( - pl.col("a").shift_and_fill(pl.col("b").mean(), periods=-2) + pl.col("a").shift_and_fill(pl.col("b").mean(), n=-2) ).collect() assert out["a"].null_count() == 0 # use df method - out = ldf.shift_and_fill(pl.col("b").std(), periods=2).collect() + out = ldf.shift_and_fill(pl.col("b").std(), n=2).collect() assert out["a"].null_count() == 0