Skip to content

Commit b722dee

Browse files
committed
BUG: force float64 dtype in object results for groupby
1 parent 35b5aed commit b722dee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/groupby.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1390,16 +1390,19 @@ def aggregate(self, values, how, axis=0):
13901390
if is_numeric_dtype(values.dtype):
13911391
values = com.ensure_float(values)
13921392
is_numeric = True
1393+
out_dtype = 'f%d' % values.dtype.itemsize
13931394
else:
13941395
is_numeric = issubclass(values.dtype.type, (np.datetime64,
13951396
np.timedelta64))
1397+
out_dtype = 'float64'
13961398
if is_numeric:
13971399
values = values.view('int64')
13981400
else:
13991401
values = values.astype(object)
14001402

14011403
# will be filled in Cython function
1402-
result = np.empty(out_shape, dtype='f%d' % values.dtype.itemsize)
1404+
result = np.empty(out_shape, dtype=out_dtype)
1405+
14031406
result.fill(np.nan)
14041407
counts = np.zeros(self.ngroups, dtype=np.int64)
14051408

0 commit comments

Comments
 (0)