带有参考列的两个数据帧的Mul列。python

带有参考列的两个数据帧的Mul列。python,python,pandas,Python,Pandas,具有参考列的两个数据帧的多列 获取错误:重新索引仅对唯一值的索引对象有效 #DF1: Country Score ----------------- 1 Ireland 0.5 2 Spain 0.25 3 USA 0.75 4 Canada 0.5 5 India 0.75 . . . Df2: --- Sup By_Id Country unique_orders ---------------------

具有参考列的两个数据帧的多列

获取错误:重新索引仅对唯一值的索引对象有效

#DF1:
  Country   Score
-----------------
1  Ireland    0.5
2  Spain      0.25 
3  USA        0.75
4  Canada     0.5
5  India      0.75
.
.
.

Df2:
---
   Sup  By_Id   Country   unique_orders
------------------------------------
1   1     1      India      210
2   2     4      CZ          20
3   3     2      Canada     321
4   1     6      Spain       30
5   2     7      India      213
.
.
想要将DF1的分数乘以与国家/地区相关的唯一订单

为此

DF2['Weighted_Score'] = DF2.unique_orders.mul(DF2.Country.map(B_Score.set_index('Country').Score))

但现在出现错误:重新索引仅对唯一值的索引对象有效

您的df1
Country
列是否有重复项?是的,我在DB相同的DF存储中多次得到此项。如果df1
Country
列有重复项,则意味着每个国家都可以有多个分数。您希望使用哪个分数来
df2