Skip to content

Commit 2efa8e5

Browse files
mroeschkephofl
authored andcommitted
DEPR: Enforce Rolling.validate/is_datetimelike/win_type deprecation (#48838)
* DEPR: Enforce Rolling.validate/is_datetimelike/win_type deprecation * Remove another test * turn test into assertion * Add whatsnew
1 parent 3cf3ec0 commit 2efa8e5

File tree

4 files changed

+8
-50
lines changed

4 files changed

+8
-50
lines changed

doc/source/whatsnew/v2.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ Removal of prior version deprecations/changes
168168
- Disallow passing positional arguments to :meth:`MultiIndex.set_levels` and :meth:`MultiIndex.set_codes` (:issue:`41485`)
169169
- Removed argument ``try_cast`` from :meth:`DataFrame.mask`, :meth:`DataFrame.where`, :meth:`Series.mask` and :meth:`Series.where` (:issue:`38836`)
170170
- Disallow passing non-round floats to :class:`Timestamp` with ``unit="M"`` or ``unit="Y"`` (:issue:`47266`)
171+
- Removed :meth:`.Rolling.validate`, :meth:`.Expanding.validate`, and :meth:`.ExponentialMovingWindow.validate` (:issue:`43665`)
172+
- Removed :attr:`Rolling.win_type` returning ``"freq"`` (:issue:`38963`)
173+
- Removed :attr:`Rolling.is_datetimelike` (:issue:`38963`)
171174
- Remove keywords ``convert_float`` and ``mangle_dupe_cols`` from :func:`read_excel` (:issue:`41176`)
172175
- Disallow passing non-keyword arguments to :func:`read_excel` except ``io`` and ``sheet_name`` (:issue:`34418`)
173176
- Removed deprecated :meth:`Timedelta.delta`, :meth:`Timedelta.is_populated`, and :attr:`Timedelta.freq` (:issue:`46430`, :issue:`46476`)

pandas/core/window/rolling.py

+2-35
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def __init__(
141141
self.window = window
142142
self.min_periods = min_periods
143143
self.center = center
144-
# TODO(2.0): Change this back to self.win_type once deprecation is enforced
145-
self._win_type = win_type
144+
self.win_type = win_type
146145
self.axis = obj._get_axis_number(axis) if axis is not None else None
147146
self.method = method
148147
self._win_freq_i8: int | None = None
@@ -165,35 +164,6 @@ def __init__(
165164
self._selection = selection
166165
self._validate()
167166

168-
@property
169-
def win_type(self):
170-
if self._win_freq_i8 is not None:
171-
warnings.warn(
172-
"win_type will no longer return 'freq' in a future version. "
173-
"Check the type of self.window instead.",
174-
FutureWarning,
175-
stacklevel=find_stack_level(),
176-
)
177-
return "freq"
178-
return self._win_type
179-
180-
@property
181-
def is_datetimelike(self) -> bool:
182-
warnings.warn(
183-
"is_datetimelike is deprecated and will be removed in a future version.",
184-
FutureWarning,
185-
stacklevel=find_stack_level(),
186-
)
187-
return self._win_freq_i8 is not None
188-
189-
def validate(self) -> None:
190-
warnings.warn(
191-
"validate is deprecated and will be removed in a future version.",
192-
FutureWarning,
193-
stacklevel=find_stack_level(),
194-
)
195-
return self._validate()
196-
197167
def _validate(self) -> None:
198168
if self.center is not None and not is_bool(self.center):
199169
raise ValueError("center must be a boolean")
@@ -331,10 +301,7 @@ def _gotitem(self, key, ndim, subset=None):
331301

332302
# we need to make a shallow copy of ourselves
333303
# with the same groupby
334-
with warnings.catch_warnings():
335-
# TODO(2.0): Remove once win_type deprecation is enforced
336-
warnings.filterwarnings("ignore", "win_type", FutureWarning)
337-
kwargs = {attr: getattr(self, attr) for attr in self._attributes}
304+
kwargs = {attr: getattr(self, attr) for attr in self._attributes}
338305

339306
selection = None
340307
if subset.ndim == 2 and (

pandas/tests/window/test_api.py

-12
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,6 @@ def test_multiple_agg_funcs(func, window_size, expected_vals):
340340
tm.assert_frame_equal(result, expected)
341341

342342

343-
def test_is_datetimelike_deprecated():
344-
s = Series(range(1)).rolling(1)
345-
with tm.assert_produces_warning(FutureWarning):
346-
assert not s.is_datetimelike
347-
348-
349-
def test_validate_deprecated():
350-
s = Series(range(1)).rolling(1)
351-
with tm.assert_produces_warning(FutureWarning):
352-
assert s.validate() is None
353-
354-
355343
@pytest.mark.filterwarnings("ignore:min_periods:FutureWarning")
356344
def test_dont_modify_attributes_after_methods(
357345
arithmetic_win_operators, closed, center, min_periods, step

pandas/tests/window/test_win_type.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ def test_consistent_win_type_freq(arg):
168168
s.rolling(arg, win_type="freq")
169169

170170

171-
def test_win_type_freq_return_deprecation():
171+
def test_win_type_freq_return_none():
172+
# GH 48838
172173
freq_roll = Series(range(2), index=date_range("2020", periods=2)).rolling("2s")
173-
with tm.assert_produces_warning(FutureWarning):
174-
assert freq_roll.win_type == "freq"
174+
assert freq_roll.win_type is None
175175

176176

177177
@td.skip_if_no_scipy

0 commit comments

Comments
 (0)