Skip to content

CLN: remove unused return value in _create_blocks #36196

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 3 commits into from
Sep 8, 2020
Merged
Changes from 2 commits
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
17 changes: 8 additions & 9 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,16 @@ def _validate_get_window_bounds_signature(window: BaseIndexer) -> None:
f"get_window_bounds"
)

def _create_blocks(self, obj: FrameOrSeriesUnion):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename these then as well, maybe _construct_data or similar

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

def _create_data(self, obj: FrameOrSeries) -> FrameOrSeries:
"""
Split data into blocks & return conformed data.
"""
# filter out the on from the object
if self.on is not None and not isinstance(self.on, Index):
if obj.ndim == 2:
obj = obj.reindex(columns=obj.columns.difference([self.on]), copy=False)
blocks = obj._to_dict_of_blocks(copy=False).values()

return blocks, obj
return obj

def _gotitem(self, key, ndim, subset=None):
"""
Expand Down Expand Up @@ -333,7 +332,7 @@ def __repr__(self) -> str:

def __iter__(self):
window = self._get_window(win_type=None)
_, obj = self._create_blocks(self._selected_obj)
obj = self._create_data(self._selected_obj)
index = self._get_window_indexer(window=window)

start, end = index.get_window_bounds(
Expand Down Expand Up @@ -469,7 +468,7 @@ def _apply_series(self, homogeneous_func: Callable[..., ArrayLike]) -> "Series":
"""
Series version of _apply_blockwise
"""
_, obj = self._create_blocks(self._selected_obj)
obj = self._create_data(self._selected_obj)

try:
values = self._prep_values(obj.values)
Expand All @@ -489,7 +488,7 @@ def _apply_blockwise(
if self._selected_obj.ndim == 1:
return self._apply_series(homogeneous_func)

_, obj = self._create_blocks(self._selected_obj)
obj = self._create_data(self._selected_obj)
mgr = obj._mgr

def hfunc(bvalues: ArrayLike) -> ArrayLike:
Expand Down Expand Up @@ -1268,7 +1267,7 @@ def count(self):
# implementations shouldn't end up here
assert not isinstance(self.window, BaseIndexer)

_, obj = self._create_blocks(self._selected_obj)
obj = self._create_data(self._selected_obj)

def hfunc(values: np.ndarray) -> np.ndarray:
result = notna(values)
Expand Down Expand Up @@ -2234,7 +2233,7 @@ def _apply(
def _constructor(self):
return Rolling

def _create_blocks(self, obj: FrameOrSeriesUnion):
def _create_data(self, obj: FrameOrSeries) -> FrameOrSeries:
"""
Split data into blocks & return conformed data.
"""
Expand All @@ -2244,7 +2243,7 @@ def _create_blocks(self, obj: FrameOrSeriesUnion):
list(self._groupby.grouper.indices.values())
).astype(np.int64)
obj = obj.take(groupby_order)
return super()._create_blocks(obj)
return super()._create_data(obj)

def _get_cython_func_type(self, func: str) -> Callable:
"""
Expand Down