Skip to content
Merged
Changes from 3 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
24 changes: 24 additions & 0 deletions pandas/tests/frame/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,30 @@ def test_sum_bools(self):
bools = isna(df)
assert bools.sum(axis=1)[0] == 10

@pytest.mark.parametrize(
"df, expected",
[
(
DataFrame({"a": ["483", "3"], "b": ["94", "759"]}),
Series(["48394", "3759"]),
),
(
DataFrame({"a": ["483.948", "3.0"], "b": ["94.2", "759.93"]}),
Series(["483.94894.2", "3.0759.93"]),
),
(
DataFrame({"a": ["483", "3.0"], "b": ["94.2", "79"]}),
Series(["48394.2", "3.079"]),
Copy link
Member

Choose a reason for hiding this comment

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

Can you put the DataFrame and Series calls in the body of the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Will make changes tonight and resubmit.

),
],
)
def test_sum_string_dtype_coercion(self, df, expected):
# GH#22642
# Check that summing numeric strings results in concatenation
# and not conversion to dtype int64 or float64
result = df.sum(axis=1)
tm.assert_series_equal(result, expected)

# ----------------------------------------------------------------------
# Index of max / min

Expand Down
Loading