97
97
all_indexes_same ,
98
98
)
99
99
import pandas .core .indexes .base as ibase
100
- from pandas .core .internals import ArrayManager
101
100
from pandas .core .series import Series
102
101
from pandas .core .util .numba_ import maybe_use_numba
103
102
@@ -1103,17 +1102,11 @@ def _cython_agg_general(
1103
1102
if numeric_only :
1104
1103
data = data .get_numeric_data (copy = False )
1105
1104
1106
- using_array_manager = isinstance (data , ArrayManager )
1107
-
1108
1105
def cast_agg_result (result : ArrayLike , values : ArrayLike ) -> ArrayLike :
1109
1106
# see if we can cast the values to the desired dtype
1110
1107
# this may not be the original dtype
1111
1108
1112
- if (
1113
- not using_array_manager
1114
- and isinstance (result .dtype , np .dtype )
1115
- and result .ndim == 1
1116
- ):
1109
+ if isinstance (result .dtype , np .dtype ) and result .ndim == 1 :
1117
1110
# We went through a SeriesGroupByPath and need to reshape
1118
1111
# GH#32223 includes case with IntegerArray values
1119
1112
# We only get here with values.dtype == object
@@ -1794,8 +1787,6 @@ def count(self) -> DataFrame:
1794
1787
ids , _ , ngroups = self .grouper .group_info
1795
1788
mask = ids != - 1
1796
1789
1797
- using_array_manager = isinstance (data , ArrayManager )
1798
-
1799
1790
def hfunc (bvalues : ArrayLike ) -> ArrayLike :
1800
1791
# TODO(2DEA): reshape would not be necessary with 2D EAs
1801
1792
if bvalues .ndim == 1 :
@@ -1805,10 +1796,6 @@ def hfunc(bvalues: ArrayLike) -> ArrayLike:
1805
1796
masked = mask & ~ isna (bvalues )
1806
1797
1807
1798
counted = lib .count_level_2d (masked , labels = ids , max_bin = ngroups , axis = 1 )
1808
- if using_array_manager :
1809
- # count_level_2d return (1, N) array for single column
1810
- # -> extract 1D array
1811
- counted = counted [0 , :]
1812
1799
return counted
1813
1800
1814
1801
new_mgr = data .grouped_reduce (hfunc )
0 commit comments