From 8ca2460deb76d81ebbcc613f7680232a199abd74 Mon Sep 17 00:00:00 2001 From: jreback Date: Tue, 25 Feb 2014 15:24:25 -0500 Subject: [PATCH] BUG: Bug in sum of a timedelta64[ns] series (GH6462) --- doc/source/release.rst | 1 + pandas/core/nanops.py | 3 ++- pandas/tseries/tests/test_timedeltas.py | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 0d3c42cdc9c33..d4ff1e0aa1e24 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -175,6 +175,7 @@ Bug Fixes - Bug in ``str.extract`` when passed a non-default index (:issue:`6348`) - Bug in ``str.split`` when passed ``pat=None`` and ``n=1`` (:issue:`6466`) - Bug in ``io.data.DataReader`` when passed ``"F-F_Momentum_Factor"`` and ``data_source="famafrench"`` (:issue:`6460`) +- Bug in ``sum`` of a ``timedelta64[ns]`` series (:issue:`6462`) pandas 0.13.1 ------------- diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 636532bc5fbf9..a47c7f82d9199 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -231,7 +231,8 @@ def nansum(values, axis=None, skipna=True): values, mask, dtype = _get_values(values, skipna, 0) the_sum = values.sum(axis) the_sum = _maybe_null_out(the_sum, axis, mask) - return the_sum + + return _wrap_results(the_sum, dtype) @disallow('M8') diff --git a/pandas/tseries/tests/test_timedeltas.py b/pandas/tseries/tests/test_timedeltas.py index 8863a50e86c2e..c490aee134a1a 100644 --- a/pandas/tseries/tests/test_timedeltas.py +++ b/pandas/tseries/tests/test_timedeltas.py @@ -207,6 +207,12 @@ def test_timedelta_ops(self): expected = to_timedelta('00:00:08') tm.assert_almost_equal(result, expected) + # GH 6462 + # consistency in returned values for sum + result = td.sum()[0] + expected = to_timedelta('00:01:21') + tm.assert_almost_equal(result, expected) + def test_to_timedelta_on_missing_values(self): _skip_if_numpy_not_friendly()