Skip to content

Commit 9a4b0a0

Browse files
authored
DEPR: rolling/expanding/ewm.validate (#43665)
1 parent d09adae commit 9a4b0a0

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

doc/source/whatsnew/v1.4.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Other Deprecations
334334
- 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`)
335335
- 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`)
336336
- Deprecated the ``index`` argument to :class:`SparseArray` construction (:issue:`23089`)
337-
-
337+
- Deprecated :meth:`.Rolling.validate`, :meth:`.Expanding.validate`, and :meth:`.ExponentialMovingWindow.validate` (:issue:`43665`)
338338

339339
.. ---------------------------------------------------------------------------
340340

pandas/core/window/rolling.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(
156156
)
157157

158158
self._selection = selection
159-
self.validate()
159+
self._validate()
160160

161161
@property
162162
def win_type(self):
@@ -180,6 +180,14 @@ def is_datetimelike(self) -> bool:
180180
return self._win_freq_i8 is not None
181181

182182
def validate(self) -> None:
183+
warnings.warn(
184+
"validate is deprecated and will be removed in a future version.",
185+
FutureWarning,
186+
stacklevel=2,
187+
)
188+
return self._validate()
189+
190+
def _validate(self) -> None:
183191
if self.center is not None and not is_bool(self.center):
184192
raise ValueError("center must be a boolean")
185193
if self.min_periods is not None:
@@ -960,8 +968,8 @@ class Window(BaseWindow):
960968
"method",
961969
]
962970

963-
def validate(self):
964-
super().validate()
971+
def _validate(self):
972+
super()._validate()
965973

966974
if not isinstance(self.win_type, str):
967975
raise ValueError(f"Invalid win_type {self.win_type}")
@@ -1528,8 +1536,8 @@ class Rolling(RollingAndExpandingMixin):
15281536
"method",
15291537
]
15301538

1531-
def validate(self):
1532-
super().validate()
1539+
def _validate(self):
1540+
super()._validate()
15331541

15341542
# we allow rolling on a datetimelike index
15351543
if (

pandas/tests/window/test_api.py

+6
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ def test_is_datetimelike_deprecated():
331331
assert not s.is_datetimelike
332332

333333

334+
def test_validate_deprecated():
335+
s = Series(range(1)).rolling(1)
336+
with tm.assert_produces_warning(FutureWarning):
337+
assert s.validate() is None
338+
339+
334340
@pytest.mark.filterwarnings("ignore:min_periods:FutureWarning")
335341
def test_dont_modify_attributes_after_methods(
336342
arithmetic_win_operators, closed, center, min_periods

0 commit comments

Comments
 (0)