15
15
import pandas ._libs .reduction as libreduction
16
16
from pandas .errors import AbstractMethodError
17
17
from pandas .util ._decorators import cache_readonly
18
+ from pandas .core .dtypes .generic import ABCMultiIndex
18
19
19
20
from pandas .core .dtypes .common import (
20
21
ensure_float64 ,
@@ -201,7 +202,7 @@ def apply(self, f, data, axis=0):
201
202
and axis == 0
202
203
# with MultiIndex, apply_frame_axis0 would raise InvalidApply
203
204
# TODO: can we make this check prettier?
204
- and not splitter ._get_sorted_data ().index . _has_complex_internals
205
+ and not isinstance ( splitter ._get_sorted_data ().index , ABCMultiIndex )
205
206
):
206
207
try :
207
208
result_values , mutated = splitter .fast_apply (f , group_keys )
@@ -212,7 +213,7 @@ def apply(self, f, data, axis=0):
212
213
return group_keys , result_values , mutated
213
214
214
215
except libreduction .InvalidApply as err :
215
- # Cannot fast apply on MultiIndex (_has_complex_internals) .
216
+ # Cannot fast apply on MultiIndex.
216
217
# This Exception is also raised if `f` triggers an exception
217
218
# but it is preferable to raise the exception in Python.
218
219
if "Let this error raise above us" not in str (err ):
@@ -698,7 +699,7 @@ def _aggregate_series_fast(self, obj, func):
698
699
699
700
# TODO: pre-empt this, also pre-empt get_result raising TypError if we pass a EA
700
701
# for EAs backed by ndarray we may have a performant workaround
701
- if obj .index . _has_complex_internals :
702
+ if isinstance ( obj .index , ABCMultiIndex )
702
703
raise TypeError ("Incompatible index for Cython grouper" )
703
704
704
705
group_index , _, ngroups = self .group_info
0 commit comments