Skip to content

Commit 22ca136

Browse files
authored
TST: add test_join_multiindex_dates (#46660)
1 parent 8a4abfa commit 22ca136

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pandas/tests/frame/methods/test_join.py

+20
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,26 @@ def test_join_multiindex_leftright(self):
345345
tm.assert_frame_equal(df1.join(df2, how="right"), exp)
346346
tm.assert_frame_equal(df2.join(df1, how="left"), exp[["value2", "value1"]])
347347

348+
def test_join_multiindex_dates(self):
349+
# GH 33692
350+
date = pd.Timestamp(2000, 1, 1).date()
351+
352+
df1_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
353+
df1 = DataFrame({"col1": [0]}, index=df1_index)
354+
df2_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
355+
df2 = DataFrame({"col2": [0]}, index=df2_index)
356+
df3_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
357+
df3 = DataFrame({"col3": [0]}, index=df3_index)
358+
359+
result = df1.join([df2, df3])
360+
361+
expected_index = MultiIndex.from_tuples([(0, date)], names=["index_0", "date"])
362+
expected = DataFrame(
363+
{"col1": [0], "col2": [0], "col3": [0]}, index=expected_index
364+
)
365+
366+
tm.assert_equal(result, expected)
367+
348368
def test_merge_join_different_levels(self):
349369
# GH#9455
350370

0 commit comments

Comments
 (0)