Skip to content

validatein merge should list out which rows are validating the condition #62742

@phofl

Description

@phofl
import pandas as pd

df = pd.DataFrame({"a": [1, 1, 3], "b": [4, 5, 6]})
df = df.merge(df, on="a", validate="one_to_one")

The error is very non-descriptive and doesn't tell you much about which rows are actually validating the condition

pandas.errors.MergeError: Merge keys are not unique in either left or right dataset; not a one-to-one merge

We should just add a suffix to this message that lists the values that are validating the condition. Probably cut off after a few values but mostly when I run into this it's one offending row that causes the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions