Skip to content

pandas/merge-without-on

Rule merge-without-on
Pack pandas
Severity warning
Fix none, edit by hand
Library versions every version

Without on=, merge joins on every column name the two frames share, so a new shared column silently changes the join. Name the keys with on=.

joined = left.merge(right, validate="many_to_one")
joined = left.merge(right, on="key", validate="many_to_one")

The rule reports merge without on=, which joins on every shared column name.

xpd has no automatic fix, so make the change by hand.

Name the key columns that you mean to join on.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

Without on=, merge joins on every column name the two frames share, so a new shared column changes the join. Name the keys with on=.

Browse the other rules of the pandas pack.