Skip to content

Commit 8835222

Browse files
mroeschkeMatt Roeschke
and
Matt Roeschke
authored
CLN: Define _constructor in window classes when needed (#38595)
Co-authored-by: Matt Roeschke <[email protected]>
1 parent 8bff5c6 commit 8835222

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

pandas/core/window/ewm.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,6 @@ def __init__(
273273
self.halflife = None
274274
self.com = get_center_of_mass(com, span, halflife, alpha)
275275

276-
@property
277-
def _constructor(self):
278-
return ExponentialMovingWindow
279-
280276
def _get_window_indexer(self) -> BaseIndexer:
281277
"""
282278
Return an indexer class that will compute the window start and end bounds
@@ -508,6 +504,10 @@ class ExponentialMovingWindowGroupby(BaseWindowGroupby, ExponentialMovingWindow)
508504
Provide an exponential moving window groupby implementation.
509505
"""
510506

507+
@property
508+
def _constructor(self):
509+
return ExponentialMovingWindow
510+
511511
def _get_window_indexer(self) -> GroupbyIndexer:
512512
"""
513513
Return an indexer class that will compute the window start and end bounds

pandas/core/window/expanding.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ class Expanding(RollingAndExpandingMixin):
6464
def __init__(self, obj, min_periods=1, center=None, axis=0, **kwargs):
6565
super().__init__(obj=obj, min_periods=min_periods, center=center, axis=axis)
6666

67-
@property
68-
def _constructor(self):
69-
return Expanding
70-
7167
def _get_window_indexer(self) -> BaseIndexer:
7268
"""
7369
Return an indexer class that will compute the window start and end bounds
@@ -281,6 +277,10 @@ class ExpandingGroupby(BaseWindowGroupby, Expanding):
281277
Provide a expanding groupby implementation.
282278
"""
283279

280+
@property
281+
def _constructor(self):
282+
return Expanding
283+
284284
def _get_window_indexer(self) -> GroupbyIndexer:
285285
"""
286286
Return an indexer class that will compute the window start and end bounds

pandas/core/window/rolling.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,6 @@ class Window(BaseWindow):
989989
2013-01-01 09:00:06 4.0
990990
"""
991991

992-
@property
993-
def _constructor(self):
994-
return Window
995-
996992
def validate(self):
997993
super().validate()
998994

@@ -1864,10 +1860,6 @@ def _on(self) -> Index:
18641860
"must be a column (of DataFrame), an Index or None"
18651861
)
18661862

1867-
@property
1868-
def _constructor(self):
1869-
return Rolling
1870-
18711863
def validate(self):
18721864
super().validate()
18731865

@@ -2123,6 +2115,10 @@ class RollingGroupby(BaseWindowGroupby, Rolling):
21232115
Provide a rolling groupby implementation.
21242116
"""
21252117

2118+
@property
2119+
def _constructor(self):
2120+
return Rolling
2121+
21262122
def _get_window_indexer(self) -> GroupbyIndexer:
21272123
"""
21282124
Return an indexer class that will compute the window start and end bounds

0 commit comments

Comments
 (0)