Skip to content

Added two tests for issue #29697 #33508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 26, 2020
Merged
Changes from 1 commit
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
33 changes: 33 additions & 0 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,39 @@ def _constructor(self):

assert isinstance(result, NotADataFrame)

def test_merge_right_duplicate_suffix(self):
Copy link
Member

Choose a reason for hiding this comment

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

These tests are very similar could you use @pytest.mark.parameterize here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added @pytest.mark.parameterize. I am not super familiar with pytest but I tried following other tests that used parameterize, but let me know about any changes I should make.

# https://github.com/pandas-dev/pandas/issues/29697

left_df = DataFrame({"A": [100, 200, 1], "B": [60, 70, 80]})
right_df = DataFrame({"A": [100, 200, 300], "B": [600, 700, 800]})

result = merge(left_df, right_df, on="A", how="right", suffixes=("_x", "_x"))
expected = DataFrame(
{"A": [100, 200, 300], "B1": [60, 70, np.nan], "B2": [600, 700, 800]}
)
expected.columns = ["A", "B_x", "B_x"]

tm.assert_frame_equal(result, expected)

def test_merge_outer_duplicate_suffix(self):
# https://github.com/pandas-dev/pandas/issues/29697

left_df = DataFrame({"A": [100, 200, 1], "B": [60, 70, 80]})
right_df = DataFrame({"A": [100, 200, 300], "B": [600, 700, 800]})

result = merge(left_df, right_df, on="A", how="outer", suffixes=("_x", "_x"))

expected = DataFrame(
{
"A": [100, 200, 1, 300],
"B1": [60, 70, 80, np.nan],
"B2": [600, 700, np.nan, 800],
}
)
expected.columns = ["A", "B_x", "B_x"]

tm.assert_frame_equal(result, expected)

def test_join_append_timedeltas(self):
# timedelta64 issues with join/merge
# GH 5695
Expand Down