Skip to content
Closed
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: 2 additions & 0 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -632,3 +632,5 @@ Bug Fixes
- Bug in ``pd.melt()`` where passing a tuple value for ``value_vars`` caused a ``TypeError`` (:issue:`15348`)
- Bug in ``.eval()`` which caused multiline evals to fail with local variables not on the first line (:issue:`15342`)
- Bug in ``pd.read_msgpack`` which did not allow to load dataframe with an index of type ``CategoricalIndex`` (:issue:`15487`)

- Bug in ``nanops.py`` due to bottleneck, which produces overflow in nansum on Windows (:issue:`15453`)
3 changes: 1 addition & 2 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def _bn_ok_dtype(dt, name):
# bottleneck does not properly upcast during the sum
# so can overflow
if name == 'nansum':
if dt.itemsize < 8:
return False
return False

return True
return False
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/test_nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def test_nansum(self):
self.check_funs(nanops.nansum, np.sum, allow_str=False,
allow_date=False, allow_tdelta=True, check_dtype=False)

def test_nansum_overflow(self):
s = Series([2**31])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs testing both with and w/o bottleneck (to yield the same results), see other tests for how to do this.

self.assertEqual(s.sum(), 2147483648)
s = Series([2**31 - 1, 1])
self.assertEqual(s.sum(), 2147483648)

def test_nanmean(self):
self.check_funs(nanops.nanmean, np.mean, allow_complex=False,
allow_obj=False, allow_str=False, allow_date=False,
Expand Down