Skip to content

TST: GH 27185 Test to check df with timedelta & Int NA sums correctly #47354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ def test_numpy_reduction_with_tz_aware_dtype(self, tz_aware_fixture, func):
result = getattr(np, func)(expected, expected)
tm.assert_series_equal(result, expected)

def test_nan_int_timedelta_sum(self):
# GH 27185
df = DataFrame(
{
"A": Series([1, 2, None], dtype="timedelta64[ns]"),
"B": Series([1, 2, None], dtype="Int64"),
Copy link
Member

Choose a reason for hiding this comment

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

Could you use NaT and NA instead of None?

}
)

result = df.sum()
assert result["A"] == Timedelta(3, "ns")
Copy link
Member

Choose a reason for hiding this comment

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

Please check the whole result object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed new commit w/ the changes requested - let me know what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey @phofl just checking in to see if there's anything I should update in the PR?

assert result["B"] == 3


class TestIndexReductions:
# Note: the name TestIndexReductions indicates these tests
Expand Down