Skip to content

DEPR: fillna method kwd #53496

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

Merged
merged 14 commits into from
Jun 7, 2023
8 changes: 8 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def pytest_collection_modifyitems(items, config) -> None:
"first is deprecated and will be removed in a future version. "
"Please create a mask and filter using `.loc` instead",
),
(
"Resampler.fillna",
"DatetimeIndexResampler.fillna is deprecated",
),
(
"DataFrameGroupBy.fillna",
"DataFrameGroupBy.fillna with 'method' is deprecated",
),
]

for item in items:
Expand Down
7 changes: 7 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7217,6 +7217,13 @@ def ffill(
2 3.0 4.0 NaN 1.0
3 3.0 3.0 NaN 4.0

>>> ser = pd.Series([1, np.NaN, 2, 3])
>>> ser.ffill()
0 1.0
1 1.0
2 2.0
3 3.0
dtype: float64
"""
self._deprecate_downcast(downcast)

Expand Down
15 changes: 7 additions & 8 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,13 @@ def fillna(self, method, limit: int | None = None):
2018-01-01 01:30:00 6.0 5
2018-01-01 02:00:00 6.0 5
"""
if method is not None:
warnings.warn(
f"{type(self).__name__}.fillna with 'method' is deprecated and "
"will raise in a future version. Use obj.ffill() or obj.bfill() "
"instead.",
FutureWarning,
stacklevel=find_stack_level(),
)
warnings.warn(
f"{type(self).__name__}.fillna is deprecated and will be removed "
"in a future version. Use obj.ffill(), obj.bfill(), "
"or obj.neaerest() instead.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: nearest

FutureWarning,
stacklevel=find_stack_level(),
)
return self._upsample(method, limit=limit)

def interpolate(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/resample/test_resample_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_fillna():
r = ts.resample("s")

expected = r.ffill()
msg = "DatetimeIndexResampler.fillna with 'method' is deprecated"
msg = "DatetimeIndexResampler.fillna is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg):
result = r.fillna(method="ffill")
tm.assert_series_equal(result, expected)
Expand Down