diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 18cafe18ae393..ce613fd78c1e1 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -686,6 +686,7 @@ Deprecations - Deprecated passing arguments as positional (except for ``"codes"``) in :meth:`MultiIndex.codes` (:issue:`41485`) - Deprecated passing arguments as positional in :meth:`Index.set_names` and :meth:`MultiIndex.set_names` (except for ``names``) (:issue:`41485`) - Deprecated passing arguments (apart from ``cond`` and ``other``) as positional in :meth:`DataFrame.mask` and :meth:`Series.mask` (:issue:`41485`) +- Deprecated passing arguments as positional in :meth:`Resampler.interpolate` (other than ``"method"``) (:issue:`41485`) - Deprecated passing arguments as positional in :meth:`DataFrame.clip` and :meth:`Series.clip` (other than ``"upper"`` and ``"lower"``) (:issue:`41485`) - Deprecated special treatment of lists with first element a Categorical in the :class:`DataFrame` constructor; pass as ``pd.DataFrame({col: categorical, ...})`` instead (:issue:`38845`) - 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`) diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 8195c18768eec..6378432392a04 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -34,6 +34,7 @@ from pandas.util._decorators import ( Appender, Substitution, + deprecate_nonkeyword_arguments, doc, ) @@ -832,6 +833,7 @@ def fillna(self, method, limit=None): """ return self._upsample(method, limit=limit) + @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"]) @doc(NDFrame.interpolate, **_shared_docs_kwargs) def interpolate( self, diff --git a/pandas/tests/resample/test_deprecated.py b/pandas/tests/resample/test_deprecated.py index fdb3a7872ad67..1f99c2888aad5 100644 --- a/pandas/tests/resample/test_deprecated.py +++ b/pandas/tests/resample/test_deprecated.py @@ -278,3 +278,30 @@ def test_resample_base_with_timedeltaindex(): tm.assert_index_equal(without_base.index, exp_without_base) tm.assert_index_equal(with_base.index, exp_with_base) + + +def test_interpolate_posargs_deprecation(): + # GH 41485 + idx = pd.to_datetime(["1992-08-27 07:46:48", "1992-08-27 07:46:59"]) + s = Series([1, 4], index=idx) + + msg = ( + r"In a future version of pandas all arguments of Resampler\.interpolate " + r"except for the argument 'method' will be keyword-only" + ) + + with tm.assert_produces_warning(FutureWarning, match=msg): + result = s.resample("3s").interpolate("linear", 0) + + idx = pd.to_datetime( + [ + "1992-08-27 07:46:48", + "1992-08-27 07:46:51", + "1992-08-27 07:46:54", + "1992-08-27 07:46:57", + ] + ) + expected = Series([1.0, 1.0, 1.0, 1.0], index=idx) + + expected.index._data.freq = "3s" + tm.assert_series_equal(result, expected)