Skip to content

pandas/merge-without-on

Pack Severity Fix Versions
pandas warning none, edit by hand All versions

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.

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=.

See all rules in the pandas pack.