[Pandas] ValueError: 'Xxx' is both an index level and a column label, which is ambiguous.
问题描述
file:[Terminal]
ValueError: 'Xxx' is both an index level and a column label, which is ambiguous.
ValueError: cannot insert Xxx, already exists
问题解决
删除两个数据帧的索引,正常以 0 开始逐步递增,如下所示:
file:[main.py]
data1.reset_index(drop=True, inplace=True)
data2.reset_index(drop=True, inplace=True)
merged_data = pd.merge(data1, data2, left_on='data1_key', right_on='data2_key')