Skip to content

Commit bc40a4a

Browse files
authored
TST: GH 27185 Test to check df with timedelta & Int NA sums correctly (#47354)
* TST: GH 27185 Adding test to check df with timedelta and int obj sums as expected * TST: updating the test with nan NaT and check whole object
1 parent 8c0dbaa commit bc40a4a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/reductions/test_reductions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,18 @@ def test_numpy_reduction_with_tz_aware_dtype(self, tz_aware_fixture, func):
198198
result = getattr(np, func)(expected, expected)
199199
tm.assert_series_equal(result, expected)
200200

201+
def test_nan_int_timedelta_sum(self):
202+
# GH 27185
203+
df = DataFrame(
204+
{
205+
"A": Series([1, 2, NaT], dtype="timedelta64[ns]"),
206+
"B": Series([1, 2, np.nan], dtype="Int64"),
207+
}
208+
)
209+
expected = Series({"A": Timedelta(3), "B": 3})
210+
result = df.sum()
211+
tm.assert_series_equal(result, expected)
212+
201213

202214
class TestIndexReductions:
203215
# Note: the name TestIndexReductions indicates these tests

0 commit comments

Comments
 (0)