Skip to content

Commit

Permalink
fixup after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed May 18, 2021
1 parent 0301254 commit 3f6e43b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
24 changes: 24 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
Appender,
Substitution,
deprecate_kwarg,
deprecate_nonkeyword_arguments,
doc,
rewrite_axis_style_signature,
)
Expand Down Expand Up @@ -10626,6 +10627,29 @@ def _values(self) -> np.ndarray:
"""internal implementation"""
return self.values

@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"])
def interpolate(
self: DataFrame,
method: str = "linear",
axis: Axis = 0,
limit: int | None = None,
inplace: bool = False,
limit_direction: str | None = None,
limit_area: str | None = None,
downcast: str | None = None,
**kwargs,
) -> DataFrame | None:
return super().interpolate(
method,
axis,
limit,
inplace,
limit_direction,
limit_area,
downcast,
**kwargs,
)


DataFrame._add_numeric_operations()

Expand Down
3 changes: 0 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
InvalidIndexError,
)
from pandas.util._decorators import (
deprecate_nonkeyword_arguments,
doc,
rewrite_axis_style_signature,
)
Expand Down Expand Up @@ -6697,8 +6696,6 @@ def replace(
else:
return result.__finalize__(self, method="replace")

@deprecate_nonkeyword_arguments(version="2.0", allowed_args=["self", "method"])
@final
def interpolate(
self: FrameOrSeries,
method: str = "linear",
Expand Down
24 changes: 24 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from pandas.util._decorators import (
Appender,
Substitution,
deprecate_nonkeyword_arguments,
doc,
)
from pandas.util._validators import (
Expand Down Expand Up @@ -5256,6 +5257,29 @@ def to_period(self, freq=None, copy=True) -> Series:
self, method="to_period"
)

@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"])
def interpolate(
self: Series,
method: str = "linear",
axis: Axis = 0,
limit: int | None = None,
inplace: bool = False,
limit_direction: str | None = None,
limit_area: str | None = None,
downcast: str | None = None,
**kwargs,
) -> Series | None:
return super().interpolate(
method,
axis,
limit,
inplace,
limit_direction,
limit_area,
downcast,
**kwargs,
)

# ----------------------------------------------------------------------
# Add index
_AXIS_ORDERS = ["index"]
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ def test_interpolate_pos_args_deprecation(self):
# https://github.com/pandas-dev/pandas/issues/41485
df = DataFrame({"a": [1, 2, 3]})
msg = (
r"Starting with Pandas version 2\.0 all arguments of interpolate except "
r"for the arguments 'self' and 'method' will be keyword-only"
r"In a future version of pandas all arguments of DataFrame.interpolate "
r"except for the argument 'method' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
df.interpolate("pad", 0)
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ def test_interpolate_pos_args_deprecation(self):
# https://github.com/pandas-dev/pandas/issues/41485
ser = Series([1, 2, 3])
msg = (
r"Starting with Pandas version 2\.0 all arguments of interpolate except "
r"for the arguments 'self' and 'method' will be keyword-only"
r"In a future version of pandas all arguments of Series.interpolate except "
r"for the argument 'method' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
ser.interpolate("pad", 0)

0 comments on commit 3f6e43b

Please sign in to comment.