26
26
is_complex_dtype ,
27
27
is_datetime64_any_dtype ,
28
28
is_datetime64tz_dtype ,
29
+ is_extension_array_dtype ,
29
30
is_integer_dtype ,
30
31
is_numeric_dtype ,
31
32
is_sparse ,
@@ -659,6 +660,12 @@ def _transform(
659
660
return result
660
661
661
662
def agg_series (self , obj , func ):
663
+ if is_extension_array_dtype (obj .dtype ) and obj .dtype .kind != "M" :
664
+ # _aggregate_series_fast would raise TypeError when
665
+ # calling libreduction.Slider
666
+ # TODO: is the datetime64tz case supposed to go through here?
667
+ return self ._aggregate_series_pure_python (obj , func )
668
+
662
669
try :
663
670
return self ._aggregate_series_fast (obj , func )
664
671
except AssertionError :
@@ -683,6 +690,8 @@ def agg_series(self, obj, func):
683
690
def _aggregate_series_fast (self , obj , func ):
684
691
func = self ._is_builtin_func (func )
685
692
693
+ # TODO: pre-empt this, also pre-empt get_result raising TypError if we pass a EA
694
+ # for EAs backed by ndarray we may have a performant workaround
686
695
if obj .index ._has_complex_internals :
687
696
raise TypeError ("Incompatible index for Cython grouper" )
688
697
@@ -717,6 +726,7 @@ def _aggregate_series_pure_python(self, obj, func):
717
726
result [label ] = res
718
727
719
728
result = lib .maybe_convert_objects (result , try_float = 0 )
729
+ # TODO: try_cast back to EA?
720
730
return result , counts
721
731
722
732
0 commit comments