@@ -140,15 +140,20 @@ def apply(self, f, data, axis=0):
140
140
group_keys = self ._get_group_keys ()
141
141
result_values = None
142
142
143
- # oh boy
144
- f_name = com .get_callable_name (f )
145
- if (
146
- f_name not in base .plotting_methods
143
+ sdata = splitter ._get_sorted_data ()
144
+ if sdata .ndim == 2 and np .any (sdata .dtypes .apply (is_extension_array_dtype )):
145
+ # calling splitter.fast_apply will raise TypeError via apply_frame_axis0
146
+ # if we pass EA instead of ndarray
147
+ # TODO: can we have a workaround for EAs backed by ndarray?
148
+ pass
149
+
150
+ elif (
151
+ com .get_callable_name (f ) not in base .plotting_methods
147
152
and hasattr (splitter , "fast_apply" )
148
153
and axis == 0
149
154
# with MultiIndex, apply_frame_axis0 would raise InvalidApply
150
155
# TODO: can we make this check prettier?
151
- and not splitter . _get_sorted_data () .index ._has_complex_internals
156
+ and not sdata .index ._has_complex_internals
152
157
):
153
158
try :
154
159
result_values , mutated = splitter .fast_apply (f , group_keys )
@@ -166,12 +171,6 @@ def apply(self, f, data, axis=0):
166
171
# TODO: can we infer anything about whether this is
167
172
# worth-retrying in pure-python?
168
173
raise
169
- except TypeError as err :
170
- if "Cannot convert" in str (err ):
171
- # via apply_frame_axis0 if we pass a non-ndarray
172
- pass
173
- else :
174
- raise
175
174
176
175
for key , (i , group ) in zip (group_keys , splitter ):
177
176
object .__setattr__ (group , "name" , key )
0 commit comments