From d7c87a025f18dc34c47acc8b4ad77fe9e60e170f Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Fri, 18 Dec 2020 13:23:26 -0800 Subject: [PATCH] CLN: Define _constructor in window classes when needed --- pandas/core/window/ewm.py | 8 ++++---- pandas/core/window/expanding.py | 8 ++++---- pandas/core/window/rolling.py | 12 ++++-------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/pandas/core/window/ewm.py b/pandas/core/window/ewm.py index f8237a436f436..9fac3a990d80b 100644 --- a/pandas/core/window/ewm.py +++ b/pandas/core/window/ewm.py @@ -270,10 +270,6 @@ def __init__( self.halflife = None self.com = get_center_of_mass(com, span, halflife, alpha) - @property - def _constructor(self): - return ExponentialMovingWindow - def _get_window_indexer(self) -> BaseIndexer: """ Return an indexer class that will compute the window start and end bounds @@ -505,6 +501,10 @@ class ExponentialMovingWindowGroupby(BaseWindowGroupby, ExponentialMovingWindow) Provide an exponential moving window groupby implementation. """ + @property + def _constructor(self): + return ExponentialMovingWindow + def _get_window_indexer(self) -> GroupbyIndexer: """ Return an indexer class that will compute the window start and end bounds diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index 94875ba86db65..f5f4dba59965c 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -64,10 +64,6 @@ class Expanding(RollingAndExpandingMixin): def __init__(self, obj, min_periods=1, center=None, axis=0, **kwargs): super().__init__(obj=obj, min_periods=min_periods, center=center, axis=axis) - @property - def _constructor(self): - return Expanding - def _get_window_indexer(self) -> BaseIndexer: """ Return an indexer class that will compute the window start and end bounds @@ -281,6 +277,10 @@ class ExpandingGroupby(BaseWindowGroupby, Expanding): Provide a expanding groupby implementation. """ + @property + def _constructor(self): + return Expanding + def _get_window_indexer(self) -> GroupbyIndexer: """ Return an indexer class that will compute the window start and end bounds diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index e6185f8ae0679..67a0cc294fe0e 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -1009,10 +1009,6 @@ class Window(BaseWindow): 2013-01-01 09:00:06 4.0 """ - @property - def _constructor(self): - return Window - def validate(self): super().validate() @@ -1884,10 +1880,6 @@ def _on(self) -> Index: "must be a column (of DataFrame), an Index or None" ) - @property - def _constructor(self): - return Rolling - def validate(self): super().validate() @@ -2143,6 +2135,10 @@ class RollingGroupby(BaseWindowGroupby, Rolling): Provide a rolling groupby implementation. """ + @property + def _constructor(self): + return Rolling + def _get_window_indexer(self) -> GroupbyIndexer: """ Return an indexer class that will compute the window start and end bounds