Skip to content

Commit 28f6ca5

Browse files
committed
dont pass Series with DTI to SeriesGrouper
1 parent 972359f commit 28f6ca5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pandas/core/groupby/ops.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@
4545
from pandas.core.frame import DataFrame
4646
from pandas.core.generic import NDFrame
4747
from pandas.core.groupby import base, grouper
48-
from pandas.core.indexes.api import Index, MultiIndex, RangeIndex, ensure_index
48+
from pandas.core.indexes.api import (
49+
DatetimeIndex,
50+
Index,
51+
MultiIndex,
52+
RangeIndex,
53+
TimedeltaIndex,
54+
ensure_index,
55+
)
4956
from pandas.core.series import Series
5057
from pandas.core.sorting import (
5158
compress_group_index,
@@ -616,7 +623,9 @@ def agg_series(self, obj: Series, func: F, *args, **kwargs):
616623
# TODO: can we get a performant workaround for EAs backed by ndarray?
617624
return self._aggregate_series_pure_python(obj, func)
618625

619-
elif obj.index._has_complex_internals or isinstance(obj.index, RangeIndex):
626+
elif obj.index._has_complex_internals or isinstance(
627+
obj.index, (RangeIndex, DatetimeIndex, TimedeltaIndex)
628+
):
620629
# Preempt TypeError in _aggregate_series_fast
621630
# exclude RangeIndex because patching it in libreduction would
622631
# silently be incorrect

0 commit comments

Comments
 (0)