-------------------------------
dfA:
-------------------------------
special_name
site_id
A Apple
B Banana
-------------------------------
dfB:
-------------------------------
42 41
site_id
A 20944 20356
B 41795 42823
我需要将特殊名称列添加到 dfB 数据框中,以便结果如下所示:
42 41 special_name
site_id
A 20944 20356 Apple
B 41795 42823 Banana
我努力了:
dfB['special_name'] = dfA['special_name']
TypeError: incompatible index of inserted column with frame index
我还尝试了尽可能多的合并、连接和连接变体。他们都有错误,例如:
dfB = dfB.join(dfA, on='site_id')
KeyError: u'no item named site_id'
任何帮助将不胜感激。