Skip to content

Commit 2feca5a

Browse files
authored
chore: Undeprecate backward_fill and forward_fill (#22156)
1 parent 012efdd commit 2feca5a

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

Diff for: py-polars/polars/expr/expr.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -2856,15 +2856,11 @@ def fill_nan(self, value: int | float | Expr | None) -> Expr:
28562856
fill_value = parse_into_expression(value, str_as_lit=True)
28572857
return self._from_pyexpr(self._pyexpr.fill_nan(fill_value))
28582858

2859-
@deprecate_function(
2860-
'Use `.fill_null(strategy="forward")` instead.', version="1.27.0"
2861-
)
28622859
def forward_fill(self, limit: int | None = None) -> Expr:
28632860
"""
28642861
Fill missing values with the last non-null value.
28652862
2866-
.. deprecated:: 1.27.0
2867-
Use :meth:`fill_null` with `strategy="forward"`.
2863+
This is an alias of `.fill_null(strategy="forward")`.
28682864
28692865
Parameters
28702866
----------
@@ -2878,15 +2874,11 @@ def forward_fill(self, limit: int | None = None) -> Expr:
28782874
"""
28792875
return self.fill_null(strategy="forward", limit=limit)
28802876

2881-
@deprecate_function(
2882-
'Use `.fill_null(strategy="backward")` instead.', version="1.27.0"
2883-
)
28842877
def backward_fill(self, limit: int | None = None) -> Expr:
28852878
"""
28862879
Fill missing values with the next non-null value.
28872880
2888-
.. deprecated:: 1.27.0
2889-
Use :meth:`fill_null` with `strategy="backward"`.
2881+
This is an alias of `.fill_null(strategy="backward")`.
28902882
28912883
Parameters
28922884
----------

Diff for: py-polars/tests/unit/dataframe/test_df.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -2011,25 +2011,21 @@ def test_fill_nan() -> None:
20112011
#
20122012
def test_forward_fill() -> None:
20132013
df = pl.DataFrame({"a": [1.0, None, 3.0]})
2014-
with pytest.deprecated_call():
2015-
fill = df.select(pl.col("a").forward_fill())["a"]
2014+
fill = df.select(pl.col("a").forward_fill())["a"]
20162015
assert_series_equal(fill, pl.Series("a", [1, 1, 3]).cast(pl.Float64))
20172016

20182017
df = pl.DataFrame({"a": [None, 1, None]})
2019-
with pytest.deprecated_call():
2020-
fill = df.select(pl.col("a").forward_fill())["a"]
2018+
fill = df.select(pl.col("a").forward_fill())["a"]
20212019
assert_series_equal(fill, pl.Series("a", [None, 1, 1]).cast(pl.Int64))
20222020

20232021

20242022
def test_backward_fill() -> None:
20252023
df = pl.DataFrame({"a": [1.0, None, 3.0]})
2026-
with pytest.deprecated_call():
2027-
fill = df.select(pl.col("a").backward_fill())["a"]
2024+
fill = df.select(pl.col("a").backward_fill())["a"]
20282025
assert_series_equal(fill, pl.Series("a", [1, 3, 3]).cast(pl.Float64))
20292026

20302027
df = pl.DataFrame({"a": [None, 1, None]})
2031-
with pytest.deprecated_call():
2032-
fill = df.select(pl.col("a").backward_fill())["a"]
2028+
fill = df.select(pl.col("a").backward_fill())["a"]
20332029
assert_series_equal(fill, pl.Series("a", [1, 1, None]).cast(pl.Int64))
20342030

20352031

0 commit comments

Comments
 (0)