Skip to content

Commit fa6d1fd

Browse files
cleanup test
1 parent 26b81c3 commit fa6d1fd

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

pandas/tests/frame/methods/test_join.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -579,37 +579,23 @@ def test_frame_join_tzaware(self):
579579
def test_frame_join_categorical_index(self):
580580
# GH 61675
581581
cat_data = pd.Categorical(
582-
[15, 16, 17, 18],
583-
categories=pd.Series(list(range(3, 24)), dtype="Int64"),
582+
[3, 4],
583+
categories=pd.Series([2, 3, 4, 5], dtype="Int64"),
584584
ordered=True,
585585
)
586-
values1 = "a b c d".split()
587-
values2 = "xyzzy foo bar ...".split()
586+
values1 = "a b".split()
587+
values2 = "foo bar".split()
588588
df1 = DataFrame({"hr": cat_data, "values1": values1}).set_index("hr")
589589
df2 = DataFrame({"hr": cat_data, "values2": values2}).set_index("hr")
590590
df1.columns = pd.CategoricalIndex([4], dtype=cat_data.dtype, name="other_hr")
591591
df2.columns = pd.CategoricalIndex([3], dtype=cat_data.dtype, name="other_hr")
592592

593-
df_joined_1 = (
594-
df1.reset_index(level="hr")
595-
.merge(df2.reset_index(level="hr"), on="hr")
596-
.set_index("hr")
597-
)
598-
expected1 = DataFrame(
599-
{"hr": cat_data, "values1": values1, "values2": values2}
600-
).set_index("hr")
601-
expected1.columns = Index([4, 3], dtype="object", name="other_hr")
602-
603-
tm.assert_frame_equal(df_joined_1, expected1)
604-
605-
df_joined_2 = df1.join(df2)
606-
expected2 = DataFrame(
593+
df_joined = df1.join(df2)
594+
expected = DataFrame(
607595
{"hr": cat_data, "values1": values1, "values2": values2}
608596
).set_index("hr")
609-
expected2.columns = pd.CategoricalIndex(
597+
expected.columns = pd.CategoricalIndex(
610598
[4, 3], dtype=cat_data.dtype, name="other_hr"
611599
)
612600

613-
tm.assert_frame_equal(df_joined_2, expected2)
614-
615-
assert df_joined_1.equals(df_joined_2)
601+
tm.assert_frame_equal(df_joined, expected)

0 commit comments

Comments
 (0)