Skip to content

Commit 3f67dc3

Browse files
ENH: Deprecate non-keyword arguments for Resampler.interpolate (#41699)
* ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * ENH: Deprecate non-keyword arguments for interpolate * Update pandas/tests/resample/test_deprecated.py Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent d466eff commit 3f67dc3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

doc/source/whatsnew/v1.3.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ Deprecations
686686
- Deprecated passing arguments as positional (except for ``"codes"``) in :meth:`MultiIndex.codes` (:issue:`41485`)
687687
- Deprecated passing arguments as positional in :meth:`Index.set_names` and :meth:`MultiIndex.set_names` (except for ``names``) (:issue:`41485`)
688688
- Deprecated passing arguments (apart from ``cond`` and ``other``) as positional in :meth:`DataFrame.mask` and :meth:`Series.mask` (:issue:`41485`)
689+
- Deprecated passing arguments as positional in :meth:`Resampler.interpolate` (other than ``"method"``) (:issue:`41485`)
689690
- Deprecated passing arguments as positional in :meth:`DataFrame.clip` and :meth:`Series.clip` (other than ``"upper"`` and ``"lower"``) (:issue:`41485`)
690691
- Deprecated special treatment of lists with first element a Categorical in the :class:`DataFrame` constructor; pass as ``pd.DataFrame({col: categorical, ...})`` instead (:issue:`38845`)
691692
- Deprecated behavior of :class:`DataFrame` constructor when a ``dtype`` is passed and the data cannot be cast to that dtype. In a future version, this will raise instead of being silently ignored (:issue:`24435`)

pandas/core/resample.py

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from pandas.util._decorators import (
3535
Appender,
3636
Substitution,
37+
deprecate_nonkeyword_arguments,
3738
doc,
3839
)
3940

@@ -832,6 +833,7 @@ def fillna(self, method, limit=None):
832833
"""
833834
return self._upsample(method, limit=limit)
834835

836+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"])
835837
@doc(NDFrame.interpolate, **_shared_docs_kwargs)
836838
def interpolate(
837839
self,

pandas/tests/resample/test_deprecated.py

+27
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,30 @@ def test_resample_base_with_timedeltaindex():
278278

279279
tm.assert_index_equal(without_base.index, exp_without_base)
280280
tm.assert_index_equal(with_base.index, exp_with_base)
281+
282+
283+
def test_interpolate_posargs_deprecation():
284+
# GH 41485
285+
idx = pd.to_datetime(["1992-08-27 07:46:48", "1992-08-27 07:46:59"])
286+
s = Series([1, 4], index=idx)
287+
288+
msg = (
289+
r"In a future version of pandas all arguments of Resampler\.interpolate "
290+
r"except for the argument 'method' will be keyword-only"
291+
)
292+
293+
with tm.assert_produces_warning(FutureWarning, match=msg):
294+
result = s.resample("3s").interpolate("linear", 0)
295+
296+
idx = pd.to_datetime(
297+
[
298+
"1992-08-27 07:46:48",
299+
"1992-08-27 07:46:51",
300+
"1992-08-27 07:46:54",
301+
"1992-08-27 07:46:57",
302+
]
303+
)
304+
expected = Series([1.0, 1.0, 1.0, 1.0], index=idx)
305+
306+
expected.index._data.freq = "3s"
307+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)