Skip to content
Closed
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
17 changes: 16 additions & 1 deletion pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,16 +1283,31 @@ def _validate(self, validate: str):
raise MergeError(
"Merge keys are not unique in left dataset; not a one-to-many merge"
)
elif right_unique:
raise MergeError(
"Merge keys are unique in right dataset; not a one-to-many merge"
)

elif validate in ["many_to_one", "m:1"]:
if not right_unique:
raise MergeError(
"Merge keys are not unique in right dataset; "
"not a many-to-one merge"
)
elif left_unique:
raise MergeError(
"Merge keys are unique in left dataset; not a many-to-one merge"
)

elif validate in ["many_to_many", "m:m"]:
pass
if left_unique:
raise MergeError(
"Merge keys are unique in left dataset; not a many-to-many merge"
)
elif right_unique:
raise MergeError(
"Merge keys are unique in right dataset; not a many-to-many merge"
)

else:
raise ValueError("Not a valid argument for validate")
Expand Down