Skip to content

Commit 1e1857f

Browse files
mroeschkeMatt Roeschke
and
Matt Roeschke
authored
CLN: Remove unnecessary rolling subclass (#36721)
* Remove unnecessary subclass * Rename _Window -> BaseWindow * Add Rolling._constructor property * Black Co-authored-by: Matt Roeschke <[email protected]>
1 parent 2300444 commit 1e1857f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

pandas/core/window/ewm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import pandas.core.common as common
1717
from pandas.core.window.common import _doc_template, _shared_docs, zsqrt
18-
from pandas.core.window.rolling import RollingMixin, flex_binary_moment
18+
from pandas.core.window.rolling import BaseWindow, flex_binary_moment
1919

2020
_bias_template = """
2121
Parameters
@@ -60,7 +60,7 @@ def get_center_of_mass(
6060
return float(comass)
6161

6262

63-
class ExponentialMovingWindow(RollingMixin):
63+
class ExponentialMovingWindow(BaseWindow):
6464
r"""
6565
Provide exponential weighted (EW) functions.
6666

pandas/core/window/rolling.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def func(arg, window, min_periods=None):
147147
return func
148148

149149

150-
class _Window(ShallowMixin, SelectionMixin):
150+
class BaseWindow(ShallowMixin, SelectionMixin):
151+
"""Provides utilities for performing windowing operations."""
152+
151153
_attributes: List[str] = [
152154
"window",
153155
"min_periods",
@@ -184,10 +186,6 @@ def __init__(
184186
self.axis = obj._get_axis_number(axis) if axis is not None else None
185187
self.validate()
186188

187-
@property
188-
def _constructor(self):
189-
return Window
190-
191189
@property
192190
def is_datetimelike(self) -> Optional[bool]:
193191
return None
@@ -862,7 +860,7 @@ def aggregate(self, func, *args, **kwargs):
862860
)
863861

864862

865-
class Window(_Window):
863+
class Window(BaseWindow):
866864
"""
867865
Provide rolling window calculations.
868866
@@ -1040,6 +1038,10 @@ class Window(_Window):
10401038
2013-01-01 09:00:06 4.0
10411039
"""
10421040

1041+
@property
1042+
def _constructor(self):
1043+
return Window
1044+
10431045
def validate(self):
10441046
super().validate()
10451047

@@ -1220,13 +1222,7 @@ def std(self, ddof=1, *args, **kwargs):
12201222
return zsqrt(self.var(ddof=ddof, name="std", **kwargs))
12211223

12221224

1223-
class RollingMixin(_Window):
1224-
@property
1225-
def _constructor(self):
1226-
return Rolling
1227-
1228-
1229-
class RollingAndExpandingMixin(RollingMixin):
1225+
class RollingAndExpandingMixin(BaseWindow):
12301226

12311227
_shared_docs["count"] = dedent(
12321228
r"""
@@ -1939,6 +1935,10 @@ def _on(self) -> Index:
19391935
"must be a column (of DataFrame), an Index or None"
19401936
)
19411937

1938+
@property
1939+
def _constructor(self):
1940+
return Rolling
1941+
19421942
def validate(self):
19431943
super().validate()
19441944

0 commit comments

Comments
 (0)