|
36 | 36 | ArrayLike,
|
37 | 37 | FrameOrSeries,
|
38 | 38 | FrameOrSeriesUnion,
|
39 |
| - Manager, |
| 39 | + Manager2D, |
40 | 40 | )
|
41 | 41 | from pandas.util._decorators import (
|
42 | 42 | Appender,
|
@@ -177,6 +177,9 @@ def pinner(cls):
|
177 | 177 | class SeriesGroupBy(GroupBy[Series]):
|
178 | 178 | _apply_allowlist = base.series_apply_allowlist
|
179 | 179 |
|
| 180 | + # Defined as a cache_readonly in SelectionMixin |
| 181 | + _obj_with_exclusions: Series |
| 182 | + |
180 | 183 | def _iterate_slices(self) -> Iterable[Series]:
|
181 | 184 | yield self._selected_obj
|
182 | 185 |
|
@@ -927,6 +930,9 @@ def pct_change(self, periods=1, fill_method="pad", limit=None, freq=None):
|
927 | 930 | @pin_allowlisted_properties(DataFrame, base.dataframe_apply_allowlist)
|
928 | 931 | class DataFrameGroupBy(GroupBy[DataFrame]):
|
929 | 932 |
|
| 933 | + # Defined as a cache_readonly in SelectionMixin |
| 934 | + _obj_with_exclusions: DataFrame |
| 935 | + |
930 | 936 | _apply_allowlist = base.dataframe_apply_allowlist
|
931 | 937 |
|
932 | 938 | _agg_examples_doc = dedent(
|
@@ -1095,9 +1101,9 @@ def _cython_agg_general(
|
1095 | 1101 |
|
1096 | 1102 | def _cython_agg_manager(
|
1097 | 1103 | self, how: str, alt=None, numeric_only: bool = True, min_count: int = -1
|
1098 |
| - ) -> Manager: |
| 1104 | + ) -> Manager2D: |
1099 | 1105 |
|
1100 |
| - data: Manager = self._get_data_to_aggregate() |
| 1106 | + data: Manager2D = self._get_data_to_aggregate() |
1101 | 1107 |
|
1102 | 1108 | if numeric_only:
|
1103 | 1109 | data = data.get_numeric_data(copy=False)
|
@@ -1691,7 +1697,7 @@ def _wrap_frame_output(self, result, obj: DataFrame) -> DataFrame:
|
1691 | 1697 | else:
|
1692 | 1698 | return self.obj._constructor(result, index=obj.index, columns=result_index)
|
1693 | 1699 |
|
1694 |
| - def _get_data_to_aggregate(self) -> Manager: |
| 1700 | + def _get_data_to_aggregate(self) -> Manager2D: |
1695 | 1701 | obj = self._obj_with_exclusions
|
1696 | 1702 | if self.axis == 1:
|
1697 | 1703 | return obj.T._mgr
|
@@ -1776,7 +1782,7 @@ def _wrap_transformed_output(
|
1776 | 1782 |
|
1777 | 1783 | return result
|
1778 | 1784 |
|
1779 |
| - def _wrap_agged_manager(self, mgr: Manager) -> DataFrame: |
| 1785 | + def _wrap_agged_manager(self, mgr: Manager2D) -> DataFrame: |
1780 | 1786 | if not self.as_index:
|
1781 | 1787 | index = np.arange(mgr.shape[1])
|
1782 | 1788 | mgr.set_axis(1, ibase.Index(index), verify_integrity=False)
|
|
0 commit comments