diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index f18b3b75ca3d2..96f4750d58d9e 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -334,7 +334,7 @@ Other Deprecations - Deprecated the 'include_start' and 'include_end' arguments in :meth:`DataFrame.between_time`; in a future version passing 'include_start' or 'include_end' will raise (:issue:`40245`) - Deprecated the ``squeeze`` argument to :meth:`read_csv`, :meth:`read_table`, and :meth:`read_excel`. Users should squeeze the DataFrame afterwards with ``.squeeze("columns")`` instead. (:issue:`43242`) - Deprecated the ``index`` argument to :class:`SparseArray` construction (:issue:`23089`) -- +- Deprecated :meth:`.Rolling.validate`, :meth:`.Expanding.validate`, and :meth:`.ExponentialMovingWindow.validate` (:issue:`43665`) .. --------------------------------------------------------------------------- diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index b3592679752fd..503a884578e8b 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -156,7 +156,7 @@ def __init__( ) self._selection = selection - self.validate() + self._validate() @property def win_type(self): @@ -180,6 +180,14 @@ def is_datetimelike(self) -> bool: return self._win_freq_i8 is not None def validate(self) -> None: + warnings.warn( + "validate is deprecated and will be removed in a future version.", + FutureWarning, + stacklevel=2, + ) + return self._validate() + + def _validate(self) -> None: if self.center is not None and not is_bool(self.center): raise ValueError("center must be a boolean") if self.min_periods is not None: @@ -960,8 +968,8 @@ class Window(BaseWindow): "method", ] - def validate(self): - super().validate() + def _validate(self): + super()._validate() if not isinstance(self.win_type, str): raise ValueError(f"Invalid win_type {self.win_type}") @@ -1528,8 +1536,8 @@ class Rolling(RollingAndExpandingMixin): "method", ] - def validate(self): - super().validate() + def _validate(self): + super()._validate() # we allow rolling on a datetimelike index if ( diff --git a/pandas/tests/window/test_api.py b/pandas/tests/window/test_api.py index 7a5fcebfd23d7..5cc22249c26f0 100644 --- a/pandas/tests/window/test_api.py +++ b/pandas/tests/window/test_api.py @@ -331,6 +331,12 @@ def test_is_datetimelike_deprecated(): assert not s.is_datetimelike +def test_validate_deprecated(): + s = Series(range(1)).rolling(1) + with tm.assert_produces_warning(FutureWarning): + assert s.validate() is None + + @pytest.mark.filterwarnings("ignore:min_periods:FutureWarning") def test_dont_modify_attributes_after_methods( arithmetic_win_operators, closed, center, min_periods