Skip to content

Commit

Permalink
CLN: Remove temp_setattr from groupby.transform (pandas-dev#55262)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach authored Sep 24, 2023
1 parent 9e1096e commit d01669f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,15 +2012,13 @@ def _transform(self, func, *args, engine=None, engine_kwargs=None, **kwargs):
# If func is a reduction, we need to broadcast the
# result to the whole group. Compute func result
# and deal with possible broadcasting below.
# Temporarily set observed for dealing with categoricals.
with com.temp_setattr(self, "observed", True):
with com.temp_setattr(self, "as_index", True):
# GH#49834 - result needs groups in the index for
# _wrap_transform_fast_result
if engine is not None:
kwargs["engine"] = engine
kwargs["engine_kwargs"] = engine_kwargs
result = getattr(self, func)(*args, **kwargs)
with com.temp_setattr(self, "as_index", True):
# GH#49834 - result needs groups in the index for
# _wrap_transform_fast_result
if engine is not None:
kwargs["engine"] = engine
kwargs["engine_kwargs"] = engine_kwargs
result = getattr(self, func)(*args, **kwargs)

return self._wrap_transform_fast_result(result)

Expand Down

0 comments on commit d01669f

Please sign in to comment.