Skip to content

REF: dont call libreduction incorrectly #41148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)

try:
return self._python_agg_general(func, *args, **kwargs)
except (ValueError, KeyError):
except KeyError:
# TODO: KeyError is raised in _python_agg_general,
# see test_groupby.test_basic
result = self._aggregate_named(func, *args, **kwargs)
Expand Down Expand Up @@ -594,6 +594,7 @@ def _transform_general(self, func, *args, **kwargs):

results = []
for name, group in self:
# this setattr is needed for test_transform_lambda_with_datetimetz
object.__setattr__(group, "name", name)
res = func(group, *args, **kwargs)

Expand Down
3 changes: 3 additions & 0 deletions pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,9 @@ def agg_series(self, obj: Series, func: F):
# preempt SeriesBinGrouper from raising TypeError
return self._aggregate_series_pure_python(obj, func)

elif obj.index._has_complex_internals:
return self._aggregate_series_pure_python(obj, func)

grouper = libreduction.SeriesBinGrouper(obj, func, self.bins)
return grouper.get_result()

Expand Down