-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
CLN: window/rolling.py #35982
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
CLN: window/rolling.py #35982
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,23 +377,15 @@ def _prep_values(self, values: Optional[np.ndarray] = None) -> np.ndarray: | |
|
||
return values | ||
|
||
def _wrap_result(self, result, block=None, obj=None): | ||
def _wrap_result(self, result: np.ndarray) -> "Series": | ||
""" | ||
Wrap a single result. | ||
Wrap a single 1D result. | ||
""" | ||
if obj is None: | ||
obj = self._selected_obj | ||
index = obj.index | ||
obj = self._selected_obj | ||
|
||
if isinstance(result, np.ndarray): | ||
|
||
if result.ndim == 1: | ||
from pandas import Series | ||
|
||
return Series(result, index, name=obj.name) | ||
from pandas import Series | ||
|
||
return type(obj)(result, index=index, columns=block.columns) | ||
return result | ||
return Series(result, obj.index, name=obj.name) | ||
|
||
def _wrap_results(self, results, obj, skipped: List[int]) -> FrameOrSeriesUnion: | ||
""" | ||
|
@@ -454,7 +446,7 @@ def _insert_on_column(self, result: "DataFrame", obj: "DataFrame"): | |
# insert at the end | ||
result[name] = extra_col | ||
|
||
def _center_window(self, result, window) -> np.ndarray: | ||
def _center_window(self, result: np.ndarray, window) -> np.ndarray: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ATM _prep_values prevents us from doing anything with EAs, but in principle is that something we'd like to support? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future yes, but I think a major blocker/consideration is that today rolling agg functions only operate on float64 inputs, so that will need to be addressed in tandem. |
||
""" | ||
Center the result in the window. | ||
""" | ||
|
@@ -513,7 +505,6 @@ def _apply_series(self, homogeneous_func: Callable[..., ArrayLike]) -> "Series": | |
Series version of _apply_blockwise | ||
""" | ||
_, obj = self._create_blocks(self._selected_obj) | ||
values = obj.values | ||
|
||
try: | ||
values = self._prep_values(obj.values) | ||
|
@@ -535,7 +526,7 @@ def _apply_blockwise( | |
|
||
# This isn't quite blockwise, since `blocks` is actually a collection | ||
# of homogenenous DataFrames. | ||
blocks, obj = self._create_blocks(self._selected_obj) | ||
_, obj = self._create_blocks(self._selected_obj) | ||
mgr = obj._mgr | ||
|
||
def hfunc(bvalues: ArrayLike) -> ArrayLike: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj._constructor?