|
15 | 15 | Callable,
|
16 | 16 | FrozenSet,
|
17 | 17 | Iterable,
|
| 18 | + List, |
18 | 19 | Mapping,
|
19 | 20 | Sequence,
|
20 | 21 | Type,
|
|
63 | 64 | )
|
64 | 65 | from pandas.core.indexes.api import Index, MultiIndex, all_indexes_same
|
65 | 66 | import pandas.core.indexes.base as ibase
|
66 |
| -from pandas.core.internals import BlockManager, make_block |
| 67 | +from pandas.core.internals import Block, BlockManager, make_block |
67 | 68 | from pandas.core.series import Series
|
68 | 69 |
|
69 | 70 | from pandas.plotting import boxplot_frame_groupby
|
@@ -987,11 +988,11 @@ def _iterate_slices(self) -> Iterable[Series]:
|
987 | 988 |
|
988 | 989 | def _cython_agg_general(
|
989 | 990 | self, how: str, alt=None, numeric_only: bool = True, min_count: int = -1
|
990 |
| - ): |
991 |
| - new_items, new_blocks = self._cython_agg_blocks( |
| 991 | + ) -> DataFrame: |
| 992 | + agg_items, agg_blocks = self._cython_agg_blocks( |
992 | 993 | how, alt=alt, numeric_only=numeric_only, min_count=min_count
|
993 | 994 | )
|
994 |
| - return self._wrap_agged_blocks(new_items, new_blocks) |
| 995 | + return self._agg_blocks_to_frame(agg_items, agg_blocks) |
995 | 996 |
|
996 | 997 | def _cython_agg_blocks(
|
997 | 998 | self, how: str, alt=None, numeric_only: bool = True, min_count: int = -1
|
@@ -1691,17 +1692,17 @@ def _wrap_transformed_output(
|
1691 | 1692 |
|
1692 | 1693 | return result
|
1693 | 1694 |
|
1694 |
| - def _wrap_agged_blocks(self, items, blocks): |
| 1695 | + def _agg_blocks_to_frame(self, items: Index, blocks: List[Block]) -> DataFrame: |
1695 | 1696 | if not self.as_index:
|
1696 | 1697 | index = np.arange(blocks[0].values.shape[-1])
|
1697 |
| - mgr = BlockManager(blocks, [items, index]) |
| 1698 | + mgr = BlockManager(blocks, axes=[items, index]) |
1698 | 1699 | result = DataFrame(mgr)
|
1699 | 1700 |
|
1700 | 1701 | self._insert_inaxis_grouper_inplace(result)
|
1701 | 1702 | result = result._consolidate()
|
1702 | 1703 | else:
|
1703 | 1704 | index = self.grouper.result_index
|
1704 |
| - mgr = BlockManager(blocks, [items, index]) |
| 1705 | + mgr = BlockManager(blocks, axes=[items, index]) |
1705 | 1706 | result = DataFrame(mgr)
|
1706 | 1707 |
|
1707 | 1708 | if self.axis == 1:
|
@@ -1751,7 +1752,7 @@ def count(self):
|
1751 | 1752 | ]
|
1752 | 1753 | blk = map(make_block, counted, loc)
|
1753 | 1754 |
|
1754 |
| - return self._wrap_agged_blocks(data.items, list(blk)) |
| 1755 | + return self._agg_blocks_to_frame(data.items, blocks=list(blk)) |
1755 | 1756 |
|
1756 | 1757 | def nunique(self, dropna: bool = True):
|
1757 | 1758 | """
|
|
0 commit comments