Skip to content

BUG: use size attribute (not method call) #7089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
BUG: force float64 dtype in object results for groupby
  • Loading branch information
cpcloud committed May 9, 2014
commit b722dee38c01b4e58dda54fc7601ff68df829514
5 changes: 4 additions & 1 deletion pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,16 +1390,19 @@ def aggregate(self, values, how, axis=0):
if is_numeric_dtype(values.dtype):
values = com.ensure_float(values)
is_numeric = True
out_dtype = 'f%d' % values.dtype.itemsize
else:
is_numeric = issubclass(values.dtype.type, (np.datetime64,
np.timedelta64))
out_dtype = 'float64'
if is_numeric:
values = values.view('int64')
else:
values = values.astype(object)

# will be filled in Cython function
result = np.empty(out_shape, dtype='f%d' % values.dtype.itemsize)
result = np.empty(out_shape, dtype=out_dtype)

result.fill(np.nan)
counts = np.zeros(self.ngroups, dtype=np.int64)

Expand Down