pandas.errors.MergeError #

异常 pandas.errors。合并错误[来源] #

合并数据时引发异常。

的子类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