Skip to content

Commit f23e884

Browse files
Update in cast handling
1 parent 29afd36 commit f23e884

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/core/groupby/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def _gotitem(self, key, ndim, subset=None):
8989
cython_transforms = frozenset(['cumprod', 'cumsum', 'shift',
9090
'cummin', 'cummax'])
9191

92-
cython_cast_blacklist = frozenset(['rank', 'count', 'size'])
92+
cython_cast_blacklist = frozenset(['rank', 'count', 'size', 'idxmin',
93+
'idxmax'])
9394

9495

9596
def whitelist_method_generator(base, klass, whitelist):

pandas/core/groupby/generic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):
255255
colg = SeriesGroupBy(data, selection=item,
256256
grouper=self.grouper)
257257

258+
cast = self._transform_should_cast(func)
259+
258260
result[item] = colg.aggregate(func, *args, **kwargs)
259-
if func != "idxmin" and func != "idxmax":
261+
if cast:
260262
result[item] = self._try_cast(result[item], data)
261263

262264
except ValueError:

0 commit comments

Comments
 (0)