Skip to content

DEPR: rolling/expanding/ewm.validate #43665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

.. ---------------------------------------------------------------------------

Expand Down
18 changes: 13 additions & 5 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __init__(
)

self._selection = selection
self.validate()
self._validate()

@property
def win_type(self):
Expand All @@ -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:
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/window/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down