【发布时间】:2016-10-10 16:29:16
【问题描述】:
我想在 Pandas 中对多个列执行合并,其中一列是索引列。
以下是示例数据框:
df1 = pd.DataFrame(np.random.rand(4,4), columns=list('ABCD'))
df2 = pd.DataFrame(np.random.rand(4,4), columns=list('EFGH'), index= [5,2,4,1])
df1['E'] = ['hello','hello','hello','world']
df2['E'] = ['world','world','hello','hello']
我想对索引和列 E 执行内部合并,这样它只会返回一行:(index,E) = (1,'hello')。
【问题讨论】: