Skip to content

Commit e70275e

Browse files
committed
CLN: DataFrameGroupBy._cython_agg_general
1 parent 0cd388f commit e70275e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pandas/core/groupby/generic.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Callable,
1616
FrozenSet,
1717
Iterable,
18+
List,
1819
Mapping,
1920
Sequence,
2021
Type,
@@ -63,7 +64,7 @@
6364
)
6465
from pandas.core.indexes.api import Index, MultiIndex, all_indexes_same
6566
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
6768
from pandas.core.series import Series
6869

6970
from pandas.plotting import boxplot_frame_groupby
@@ -987,11 +988,11 @@ def _iterate_slices(self) -> Iterable[Series]:
987988

988989
def _cython_agg_general(
989990
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(
992993
how, alt=alt, numeric_only=numeric_only, min_count=min_count
993994
)
994-
return self._wrap_agged_blocks(new_items, new_blocks)
995+
return self._agg_blocks_to_frame(agg_items, agg_blocks)
995996

996997
def _cython_agg_blocks(
997998
self, how: str, alt=None, numeric_only: bool = True, min_count: int = -1
@@ -1691,17 +1692,17 @@ def _wrap_transformed_output(
16911692

16921693
return result
16931694

1694-
def _wrap_agged_blocks(self, items, blocks):
1695+
def _agg_blocks_to_frame(self, items: Index, blocks: List[Block]) -> DataFrame:
16951696
if not self.as_index:
16961697
index = np.arange(blocks[0].values.shape[-1])
1697-
mgr = BlockManager(blocks, [items, index])
1698+
mgr = BlockManager(blocks, axes=[items, index])
16981699
result = DataFrame(mgr)
16991700

17001701
self._insert_inaxis_grouper_inplace(result)
17011702
result = result._consolidate()
17021703
else:
17031704
index = self.grouper.result_index
1704-
mgr = BlockManager(blocks, [items, index])
1705+
mgr = BlockManager(blocks, axes=[items, index])
17051706
result = DataFrame(mgr)
17061707

17071708
if self.axis == 1:
@@ -1751,7 +1752,7 @@ def count(self):
17511752
]
17521753
blk = map(make_block, counted, loc)
17531754

1754-
return self._wrap_agged_blocks(data.items, list(blk))
1755+
return self._agg_blocks_to_frame(data.items, blocks=list(blk))
17551756

17561757
def nunique(self, dropna: bool = True):
17571758
"""

0 commit comments

Comments
 (0)