Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def trans(x):
r = result.ravel()
arr = np.array([r[0]])

if isna(arr).any() or not np.allclose(arr, trans(arr).astype(dtype), rtol=0):
if isna(arr).any():
# if we have any nulls, then we are done
return result

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def aggregate(self, func=None, *args, **kwargs):

try:
return self._python_agg_general(func, *args, **kwargs)
except AssertionError:
except (AssertionError, TypeError):
raise
except Exception:
result = self._aggregate_named(func, *args, **kwargs)
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/dtypes/cast/test_downcast.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import decimal

import numpy as np
import pytest

Expand Down Expand Up @@ -25,6 +27,13 @@
"infer",
np.array([8, 8, 8, 8, 9], dtype=np.int64),
),
(
# This is a judgement call, but we do _not_ downcast Decimal
# objects
np.array([decimal.Decimal(0.0)]),
"int64",
np.array([decimal.Decimal(0.0)]),
),
],
)
def test_downcast(arr, expected, dtype):
Expand Down