Skip to content

Commit 4d26933

Browse files
committed
changes according to comments
1 parent e70275e commit 4d26933

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pandas/core/groupby/generic.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from textwrap import dedent
1212
import typing
1313
from typing import (
14+
TYPE_CHECKING,
1415
Any,
1516
Callable,
1617
FrozenSet,
@@ -64,11 +65,15 @@
6465
)
6566
from pandas.core.indexes.api import Index, MultiIndex, all_indexes_same
6667
import pandas.core.indexes.base as ibase
67-
from pandas.core.internals import Block, BlockManager, make_block
68+
from pandas.core.internals import BlockManager, make_block
6869
from pandas.core.series import Series
6970

7071
from pandas.plotting import boxplot_frame_groupby
7172

73+
if TYPE_CHECKING:
74+
from pandas.core.internals import Block
75+
76+
7277
NamedAgg = namedtuple("NamedAgg", ["column", "aggfunc"])
7378
# TODO(typing) the return value on this callable should be any *scalar*.
7479
AggScalar = Union[str, Callable[..., Any]]
@@ -1692,7 +1697,7 @@ def _wrap_transformed_output(
16921697

16931698
return result
16941699

1695-
def _agg_blocks_to_frame(self, items: Index, blocks: List[Block]) -> DataFrame:
1700+
def _agg_blocks_to_frame(self, items: Index, blocks: List["Block"]) -> DataFrame:
16961701
if not self.as_index:
16971702
index = np.arange(blocks[0].values.shape[-1])
16981703
mgr = BlockManager(blocks, axes=[items, index])
@@ -1750,9 +1755,9 @@ def count(self):
17501755
counted = [
17511756
lib.count_level_2d(x, labels=ids, max_bin=ngroups, axis=1) for x in val
17521757
]
1753-
blk = map(make_block, counted, loc)
1758+
blocks = map(make_block, counted, loc)
17541759

1755-
return self._agg_blocks_to_frame(data.items, blocks=list(blk))
1760+
return self._agg_blocks_to_frame(data.items, blocks=list(blocks))
17561761

17571762
def nunique(self, dropna: bool = True):
17581763
"""

0 commit comments

Comments
 (0)