我正在尝试合并两个数据框,但始终收到“检查重复错误”。这是数据框的布局:
DF1:
City State Sales
San Fran CA $10
Col OH $5
Col SC $5
DF2:
City State Percent
Col OH 3%
Col SC 10%
New York NY 12%
所需结果:
DF3:
City State Sales Percent
San Fran CA $10 0
Col OH $5 3%
Col SC $5 10
New York NY 0 12%
以下代码给了我错误
df3 = pd.merge(df1, df2, how='outer', on=['City','State'])
KeyError: 'City'
关于我在做什么错的任何想法吗?