Skip to content

Commit d01669f

Browse files
authored
CLN: Remove temp_setattr from groupby.transform (#55262)
1 parent 9e1096e commit d01669f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pandas/core/groupby/groupby.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -2012,15 +2012,13 @@ def _transform(self, func, *args, engine=None, engine_kwargs=None, **kwargs):
20122012
# If func is a reduction, we need to broadcast the
20132013
# result to the whole group. Compute func result
20142014
# and deal with possible broadcasting below.
2015-
# Temporarily set observed for dealing with categoricals.
2016-
with com.temp_setattr(self, "observed", True):
2017-
with com.temp_setattr(self, "as_index", True):
2018-
# GH#49834 - result needs groups in the index for
2019-
# _wrap_transform_fast_result
2020-
if engine is not None:
2021-
kwargs["engine"] = engine
2022-
kwargs["engine_kwargs"] = engine_kwargs
2023-
result = getattr(self, func)(*args, **kwargs)
2015+
with com.temp_setattr(self, "as_index", True):
2016+
# GH#49834 - result needs groups in the index for
2017+
# _wrap_transform_fast_result
2018+
if engine is not None:
2019+
kwargs["engine"] = engine
2020+
kwargs["engine_kwargs"] = engine_kwargs
2021+
result = getattr(self, func)(*args, **kwargs)
20242022

20252023
return self._wrap_transform_fast_result(result)
20262024

0 commit comments

Comments
 (0)