|
11 | 11 | from textwrap import dedent
|
12 | 12 | import typing
|
13 | 13 | from typing import (
|
| 14 | + TYPE_CHECKING, |
14 | 15 | Any,
|
15 | 16 | Callable,
|
16 | 17 | FrozenSet,
|
|
64 | 65 | )
|
65 | 66 | from pandas.core.indexes.api import Index, MultiIndex, all_indexes_same
|
66 | 67 | 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 |
68 | 69 | from pandas.core.series import Series
|
69 | 70 |
|
70 | 71 | from pandas.plotting import boxplot_frame_groupby
|
71 | 72 |
|
| 73 | +if TYPE_CHECKING: |
| 74 | + from pandas.core.internals import Block |
| 75 | + |
| 76 | + |
72 | 77 | NamedAgg = namedtuple("NamedAgg", ["column", "aggfunc"])
|
73 | 78 | # TODO(typing) the return value on this callable should be any *scalar*.
|
74 | 79 | AggScalar = Union[str, Callable[..., Any]]
|
@@ -1692,7 +1697,7 @@ def _wrap_transformed_output(
|
1692 | 1697 |
|
1693 | 1698 | return result
|
1694 | 1699 |
|
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: |
1696 | 1701 | if not self.as_index:
|
1697 | 1702 | index = np.arange(blocks[0].values.shape[-1])
|
1698 | 1703 | mgr = BlockManager(blocks, axes=[items, index])
|
@@ -1750,9 +1755,9 @@ def count(self):
|
1750 | 1755 | counted = [
|
1751 | 1756 | lib.count_level_2d(x, labels=ids, max_bin=ngroups, axis=1) for x in val
|
1752 | 1757 | ]
|
1753 |
| - blk = map(make_block, counted, loc) |
| 1758 | + blocks = map(make_block, counted, loc) |
1754 | 1759 |
|
1755 |
| - return self._agg_blocks_to_frame(data.items, blocks=list(blk)) |
| 1760 | + return self._agg_blocks_to_frame(data.items, blocks=list(blocks)) |
1756 | 1761 |
|
1757 | 1762 | def nunique(self, dropna: bool = True):
|
1758 | 1763 | """
|
|
0 commit comments