-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
CLN: Consistent and Annotated Return Type of _iterate_slices #28958
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
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 |
|---|---|---|
|
|
@@ -11,7 +11,17 @@ | |
| from functools import partial | ||
| from textwrap import dedent | ||
| import typing | ||
| from typing import Any, Callable, FrozenSet, Sequence, Type, Union | ||
| from typing import ( | ||
| Any, | ||
| Callable, | ||
| FrozenSet, | ||
| Hashable, | ||
| Iterator, | ||
| Sequence, | ||
| Tuple, | ||
| Type, | ||
| Union, | ||
| ) | ||
| import warnings | ||
|
|
||
| import numpy as np | ||
|
|
@@ -132,7 +142,7 @@ def pinner(cls): | |
| class SeriesGroupBy(GroupBy): | ||
| _apply_whitelist = base.series_apply_whitelist | ||
|
|
||
| def _iterate_slices(self): | ||
| def _iterate_slices(self) -> Iterator[Tuple[Hashable, Series]]: | ||
| yield self._selection_name, self._selected_obj | ||
|
|
||
| @property | ||
|
|
@@ -898,22 +908,20 @@ def aggregate(self, func=None, *args, **kwargs): | |
|
|
||
| agg = aggregate | ||
|
|
||
| def _iterate_slices(self): | ||
| if self.axis == 0: | ||
| # kludge | ||
| if self._selection is None: | ||
| slice_axis = self.obj.columns | ||
| else: | ||
| slice_axis = self._selection_list | ||
| slicer = lambda x: self.obj[x] | ||
| def _iterate_slices(self) -> Iterator[Tuple[Hashable, Series]]: | ||
| obj = self._selected_obj.copy() | ||
|
||
| if self.axis == 1: | ||
| obj = obj.T | ||
|
|
||
| if isinstance(obj, Series) and obj.name not in self.exclusions: | ||
| # Occurs when doing DataFrameGroupBy(...)["X"] | ||
| yield obj.name, obj | ||
| else: | ||
| slice_axis = self.obj.index | ||
| slicer = self.obj.xs | ||
| for label, values in obj.items(): | ||
| if label in self.exclusions: | ||
| continue | ||
|
|
||
| for val in slice_axis: | ||
| if val in self.exclusions: | ||
| continue | ||
| yield val, slicer(val) | ||
| yield label, values | ||
|
|
||
| def _cython_agg_general(self, how, alt=None, numeric_only=True, min_count=-1): | ||
| new_items, new_blocks = self._cython_agg_blocks( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.