Skip to content
Open
Changes from all 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
21 changes: 21 additions & 0 deletions pandas/tests/frame/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,27 @@ def test_arithmetic_multiindex_column_align_with_fillvalue():
tm.assert_frame_equal(result, expected)


def test_arithmetic_multiindex_add_with_mixed_string_datetime_index():
# GH#26558
df1 = DataFrame(
data=[10],
index=MultiIndex.from_tuples([("Z", "2019-05-31")]),
columns=["A"],
)
df2 = DataFrame(
data=[20],
index=MultiIndex.from_tuples([("Z", datetime(2019, 5, 31))]),
columns=["A"],
)

with tm.assert_produces_warning(RuntimeWarning, match="are unorderable"):
result = df1.add(df2, fill_value=0)

assert len(result) == 2
assert result.loc[("Z", "2019-05-31"), "A"] == 10
assert result.loc[("Z", datetime(2019, 5, 31)), "A"] == 20
Comment on lines +2171 to +2173
Copy link
Member

Choose a reason for hiding this comment

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

Whenever possible, test the full state of the result.

expected = DataFrame(...)
tm.assert_frame_equal(result, expected)



def test_bool_frame_mult_float():
# GH 18549
df = DataFrame(True, list("ab"), list("cd"))
Expand Down
Loading