Skip to content

REF: pandas/core/window.py into multiple files #27736

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 8 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 11 additions & 7 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10690,9 +10690,13 @@ def _add_series_or_dataframe_operations(cls):
the doc strings again.
"""

from pandas.core import window as rwindow
from pandas.core.window import (
ewm as lib_ewm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually call the _libs imports like libwindow (etc), so is there a reason you can't just
from pandas.core.window import ewm, expanding, rolling? (or else I guess would be ok to call libewm, etc)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just directly import what you need from these modules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused a RecursionError since the defined functions here are:

def rolling(...):
    return rolling(...)

cls.rolling = rolling

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I was able to use more direct imports, and all green.

expanding as lib_expanding,
rolling as lib_rolling,
)

@Appender(rwindow.rolling.__doc__)
@Appender(lib_rolling.rolling.__doc__)
def rolling(
self,
window,
Expand All @@ -10704,7 +10708,7 @@ def rolling(
closed=None,
):
axis = self._get_axis_number(axis)
return rwindow.rolling(
return lib_rolling.rolling(
self,
window=window,
min_periods=min_periods,
Expand All @@ -10717,16 +10721,16 @@ def rolling(

cls.rolling = rolling

@Appender(rwindow.expanding.__doc__)
@Appender(lib_expanding.expanding.__doc__)
def expanding(self, min_periods=1, center=False, axis=0):
axis = self._get_axis_number(axis)
return rwindow.expanding(
return lib_expanding.expanding(
self, min_periods=min_periods, center=center, axis=axis
)

cls.expanding = expanding

@Appender(rwindow.ewm.__doc__)
@Appender(lib_ewm.ewm.__doc__)
def ewm(
self,
com=None,
Expand All @@ -10739,7 +10743,7 @@ def ewm(
axis=0,
):
axis = self._get_axis_number(axis)
return rwindow.ewm(
return lib_ewm.ewm(
self,
com=com,
span=span,
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ def rolling(self, *args, **kwargs):
"""
Return a rolling grouper, providing rolling functionality per group.
"""
from pandas.core.window import RollingGroupby
from pandas.core.window.rolling import RollingGroupby

return RollingGroupby(self, *args, **kwargs)

Expand All @@ -1574,7 +1574,7 @@ def expanding(self, *args, **kwargs):
Return an expanding grouper, providing expanding
functionality per group.
"""
from pandas.core.window import ExpandingGroupby
from pandas.core.window.expanding import ExpandingGroupby

return ExpandingGroupby(self, *args, **kwargs)

Expand Down
Empty file added pandas/core/window/__init__.py
Empty file.
Loading