Skip to content

Commit

Permalink
TST: add test_join_multiindex_dates (#46660)
Browse files Browse the repository at this point in the history
  • Loading branch information
dospix authored Apr 7, 2022
1 parent 8a4abfa commit 22ca136
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pandas/tests/frame/methods/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,26 @@ def test_join_multiindex_leftright(self):
tm.assert_frame_equal(df1.join(df2, how="right"), exp)
tm.assert_frame_equal(df2.join(df1, how="left"), exp[["value2", "value1"]])

def test_join_multiindex_dates(self):
# GH 33692
date = pd.Timestamp(2000, 1, 1).date()

df1_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
df1 = DataFrame({"col1": [0]}, index=df1_index)
df2_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
df2 = DataFrame({"col2": [0]}, index=df2_index)
df3_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
df3 = DataFrame({"col3": [0]}, index=df3_index)

result = df1.join([df2, df3])

expected_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
expected = DataFrame(
{"col1": [0], "col2": [0], "col3": [0]}, index=expected_index
)

tm.assert_equal(result, expected)

def test_merge_join_different_levels(self):
# GH#9455

Expand Down

0 comments on commit 22ca136

Please sign in to comment.