Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ Numeric
- Bug in :meth:`Series.any`, :meth:`Series.all`, :meth:`DataFrame.any`, and :meth:`DataFrame.all` had the default value of ``bool_only`` set to ``None`` instead of ``False``; this change should have no impact on users (:issue:`53258`)
- Bug in :meth:`Series.corr` and :meth:`Series.cov` raising ``AttributeError`` for masked dtypes (:issue:`51422`)
- Bug in :meth:`Series.median` and :meth:`DataFrame.median` with object-dtype values containing strings that can be converted to numbers (e.g. "2") returning incorrect numeric results; these now raise ``TypeError`` (:issue:`34671`)
- Bug in :meth:`Series.sum` converting dtype ``uint64`` to ``int64`` (:issue:`53401`)


Conversion
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,10 @@ def _get_values(
def _get_dtype_max(dtype: np.dtype) -> np.dtype:
# return a platform independent precision dtype
dtype_max = dtype
if dtype.kind in "biu":
if dtype.kind in "bi":
dtype_max = np.dtype(np.int64)
elif dtype.kind == "u":
dtype_max = np.dtype(np.uint64)
elif dtype.kind == "f":
dtype_max = np.dtype(np.float64)
return dtype_max
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/series/methods/test_sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import numpy as np

from pandas import Series
import pandas._testing as tm


class TestSeriesSum:
def test_sum_uint64(self):
# GH 53401
s = Series([10000000000000000000], dtype="uint64")
result = s.sum()
expected = np.uint64(10000000000000000000)
tm.assert_almost_equal(result, expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move the test over to pandas.tests.reductions.test_reductions.TestSeriesReductions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! That seems right place.