Python 从索引为+的数据帧中删除重复项;行匹配

Python 从索引为+的数据帧中删除重复项;行匹配,python,pandas,Python,Pandas,我有两个pandasDataFrames,我想将它们连接在一起,以便在删除重复项的情况下获得外部连接。我的问题是.drop\u duplicates()在查找重复项时忽略索引。如果索引不同,则不应重复。如果行索引和列是重复的,如何删除重复项?我唯一能想到的就是使用df.to_dict(),然后创建一个新的数据帧(效率非常低) 更新: a.combine_first(b) 根据要求,以下是我的数据示例: from pandas import * index1 = ['2012-05-2' + s

我有两个
pandas
DataFrame
s,我想将它们连接在一起,以便在删除重复项的情况下获得外部连接。我的问题是
.drop\u duplicates()
在查找重复项时忽略索引。如果索引不同,则不应重复。如果行索引和列是重复的,如何删除重复项?我唯一能想到的就是使用
df.to_dict()
,然后创建一个新的数据帧(效率非常低)

更新:

a.combine_first(b)
根据要求,以下是我的数据示例:

from pandas import *
index1 = ['2012-05-2' + str(i) for i in range(0,6)]
data1 = {'rate': range(0,6)}
a = DataFrame(data1, index1)

index2 = ['2012-05-2' + str(i) for i in range(3,9)]
data2 = {'rate': range(3,9)}
b = DataFrame(data2, index2)

格伦解决方案:

a.combine_first(b)

谢谢,韦斯。

你检查过你想要什么吗?否则,您能否给出一个数据示例以及您期望/希望得到的结果?您是否尝试过使用
pandas.merge(A,B,method=“outer”)