Skip to content

Commit a20386b

Browse files
committed
_agg_blocks_to_frame -> _wrap_agged_blocks + cleaning
1 parent b87e0b9 commit a20386b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pandas/core/groupby/generic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def _cython_agg_general(
997997
agg_items, agg_blocks = self._cython_agg_blocks(
998998
how, alt=alt, numeric_only=numeric_only, min_count=min_count
999999
)
1000-
return self._agg_blocks_to_frame(agg_items, agg_blocks)
1000+
return self._wrap_agged_blocks(agg_blocks, items=agg_items)
10011001

10021002
def _cython_agg_blocks(
10031003
self, how: str, alt=None, numeric_only: bool = True, min_count: int = -1
@@ -1697,7 +1697,7 @@ def _wrap_transformed_output(
16971697

16981698
return result
16991699

1700-
def _agg_blocks_to_frame(self, items: Index, blocks: "List[Block]") -> DataFrame:
1700+
def _wrap_agged_blocks(self, blocks: "List[Block]", items: Index) -> DataFrame:
17011701
if not self.as_index:
17021702
index = np.arange(blocks[0].values.shape[-1])
17031703
mgr = BlockManager(blocks, axes=[items, index])
@@ -1746,18 +1746,18 @@ def count(self):
17461746
ids, _, ngroups = self.grouper.group_info
17471747
mask = ids != -1
17481748

1749-
val = (
1749+
vals = (
17501750
(mask & ~_isna_ndarraylike(np.atleast_2d(blk.get_values())))
17511751
for blk in data.blocks
17521752
)
1753-
loc = (blk.mgr_locs for blk in data.blocks)
1753+
locs = (blk.mgr_locs for blk in data.blocks)
17541754

17551755
counted = [
1756-
lib.count_level_2d(x, labels=ids, max_bin=ngroups, axis=1) for x in val
1756+
lib.count_level_2d(x, labels=ids, max_bin=ngroups, axis=1) for x in vals
17571757
]
1758-
blocks = map(make_block, counted, loc)
1758+
blocks = [make_block(val, placement=loc) for val, loc in zip(counted, locs)]
17591759

1760-
return self._agg_blocks_to_frame(data.items, blocks=list(blocks))
1760+
return self._wrap_agged_blocks(blocks, items=data.items)
17611761

17621762
def nunique(self, dropna: bool = True):
17631763
"""

0 commit comments

Comments
 (0)