Skip to content

pandas/merge-without-validate

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

A merge without validate= duplicates rows without a warning when a key repeats. Pass validate= with the relation you expect, such as "many_to_one".

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

The rule reports merge without validate=, which duplicates rows without a warning when a key repeats. The rule leaves a merge with how="cross" alone, because it pairs every row on purpose, and a merge with how="left_anti" or how="right_anti", because an anti join keeps each row of one frame at most once.

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

Pick the validate value that matches your data, because "many_to_one" is only the example. "many_to_many" checks nothing.

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

merge without validate= can silently duplicate rows.

Browse the other rules of the pandas pack.