Skip to content

Commit 6383436

Browse files
committed
ENH: perf enh, only cast to float if numeric already
1 parent 153b16c commit 6383436

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/core/groupby.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,10 @@ def _cython_agg_general(self, how):
333333
output = {}
334334
cannot_agg = []
335335
for name, obj in self._iterate_slices():
336-
try:
337-
obj = np.asarray(obj, dtype=float)
338-
except ValueError:
336+
if issubclass(obj.dtype.type, np.number):
337+
if obj.dtype != np.float64:
338+
obj = obj.astype('f8')
339+
else:
339340
cannot_agg.append(name)
340341
continue
341342

0 commit comments

Comments
 (0)