Skip to content

Commit

Permalink
REF: remove unnecessary _try_cast calls (pandas-dev#29642)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and Mateusz Górski committed Nov 18, 2019
1 parent 4fe3338 commit 775d0c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def _aggregate_named(self, func, *args, **kwargs):
output = func(group, *args, **kwargs)
if isinstance(output, (Series, Index, np.ndarray)):
raise ValueError("Must produce aggregated value")
result[name] = self._try_cast(output, group)
result[name] = output

return result

Expand Down
8 changes: 0 additions & 8 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,14 +1357,6 @@ def f(self, **kwargs):

# apply a non-cython aggregation
result = self.aggregate(lambda x: npfunc(x, axis=self.axis))

# coerce the resulting columns if we can
if isinstance(result, DataFrame):
for col in result.columns:
result[col] = self._try_cast(result[col], self.obj[col])
else:
result = self._try_cast(result, self.obj)

return result

set_function_name(f, name, cls)
Expand Down

0 comments on commit 775d0c1

Please sign in to comment.