pandas.errors.MergeError#

exceptionpandas.errors.MergeError[source] #

Exception raised when merging data.

Subclass of ValueError.

See also

DataFrame.join

For joining DataFrames on their indexes.

merge

For merging two DataFrames on a common set of keys.

Examples

>>> left = pd.DataFrame(
...  {"a": ["a", "b", "b", "d"], "b": ["cat", "dog", "weasel", "horse"]},
...  index=range(4),
... )
>>> right = pd.DataFrame(
...  {"a": ["a", "b", "c", "d"], "c": ["meow", "bark", "chirp", "nay"]},
...  index=range(4),
... ).set_index("a")
>>> left.join(
...  right,
...  on="a",
...  validate="one_to_one",
... )
Traceback (most recent call last):
MergeError: Merge keys are not unique in left dataset; not a one-to-one merge
On this page

This Page