Skip to content

Commit

Permalink
allow method to be positional
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed May 17, 2021
1 parent f1ac08b commit a748a15
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ Deprecations
- Deprecated setting :attr:`Categorical._codes`, create a new :class:`Categorical` with the desired codes instead (:issue:`40606`)
- Deprecated behavior of :meth:`DatetimeIndex.union` with mixed timezones; in a future version both will be cast to UTC instead of object dtype (:issue:`39328`)
- Deprecated using ``usecols`` with out of bounds indices for ``read_csv`` with ``engine="c"`` (:issue:`25623`)
- Deprecated passing arguments as positional in :meth:`DataFrame.interpolate` and :meth:`Series.interpolate` (:issue:`41485`)
- Deprecated passing arguments as positional (except for ``"method"``) in :meth:`DataFrame.interpolate` and :meth:`Series.interpolate` (:issue:`41485`)

.. ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6697,7 +6697,7 @@ def replace(
else:
return result.__finalize__(self, method="replace")

@deprecate_nonkeyword_arguments(version="2.0", allowed_args=["self"])
@deprecate_nonkeyword_arguments(version="2.0", allowed_args=["self", "method"])
@final
def interpolate(
self: FrameOrSeries,
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 @@ -348,7 +348,7 @@ def test_interpolate_pos_args_deprecation(self):
df = DataFrame({"a": [1, 2, 3]})
msg = (
r"Starting with Pandas version 2\.0 all arguments of interpolate except "
r"for the argument 'self' will be keyword-only"
r"for the arguments 'self' and 'method' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
df.interpolate(0)
df.interpolate("pad", 0)
8 changes: 3 additions & 5 deletions pandas/tests/resample/test_datetime_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,14 +1026,12 @@ def test_resample_dtype_coercion():
df = {"a": [1, 3, 1, 4]}
df = DataFrame(df, index=date_range("2017-01-01", "2017-01-04"))

expected = (
df.astype("float64").resample("H").mean()["a"].interpolate(method="cubic")
)
expected = df.astype("float64").resample("H").mean()["a"].interpolate("cubic")

result = df.resample("H")["a"].mean().interpolate(method="cubic")
result = df.resample("H")["a"].mean().interpolate("cubic")
tm.assert_series_equal(result, expected)

result = df.resample("H").mean()["a"].interpolate(method="cubic")
result = df.resample("H").mean()["a"].interpolate("cubic")
tm.assert_series_equal(result, expected)


Expand Down
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 @@ -817,7 +817,7 @@ def test_interpolate_pos_args_deprecation(self):
ser = Series([1, 2, 3])
msg = (
r"Starting with Pandas version 2\.0 all arguments of interpolate except "
r"for the argument 'self' will be keyword-only"
r"for the arguments 'self' and 'method' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
ser.interpolate(0)
ser.interpolate("pad", 0)

0 comments on commit a748a15

Please sign in to comment.