Skip to content

Commit 79e9055

Browse files
committed
move merge type validation to _MergeOperation class
1 parent 775b8b9 commit 79e9055

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pandas/core/reshape/merge.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,7 @@ def merge(
350350
left_df = _validate_operand(left)
351351
left._check_copy_deprecation(copy)
352352
right_df = _validate_operand(right)
353-
merge_type = ["left", "right", "inner", "outer", "cross"]
354-
if how not in merge_type:
355-
raise ValueError(f"'{how}' is not a valid Merge type ({merge_type})")
356-
elif how == "cross":
353+
if how == "cross":
357354
return _cross_merge(
358355
left_df,
359356
right_df,
@@ -985,6 +982,11 @@ def __init__(
985982
)
986983
raise MergeError(msg)
987984

985+
# GH 59435: raise when "how" is not a valid Merge type
986+
merge_type = ("left", "right", "inner", "outer", "cross", "asof")
987+
if how not in merge_type:
988+
raise ValueError(f"'{how}' is not a valid Merge type {merge_type}")
989+
988990
self.left_on, self.right_on = self._validate_left_right_on(left_on, right_on)
989991

990992
(

0 commit comments

Comments
 (0)