pandas.errors.MergeError#

exception pandas.errors.MergeError[源代码][源代码]#

合并数据时引发的异常。

ValueError 的子类。

例子

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