我有一个叫做
rawReturn
Identifier Entry Date Route to current team concatenated
0 12884 .. 01/01/2012 TRANSFER SMITHROBERT
1 10604 .. 04/07/2013 EXTERNAL JONESAMY
2 14445 .. 16/07/2018 EXTERNAL EVANSSTEVEN
3 7898 .. 03/09/2010 LOAN HILLEMMA
: : .. : : :
34578 10487 .. 01/07/2012 TRANSFER DENSMARCUS
34579 13016 .. 02/06/2014 EXTERNAL WHITECHRIS
34580 12885 .. 09/08/2016 LOAN COLESDAVID
34581 .. 05/08/2014 EXTERNAL KINGHELEN
我还有另一个数据帧叫做
df
其中有我想应用于
数据帧。在下面的例子中,我试图更新到
Route to current team
列使用以下
测向
数据框,如下所示:
Identifier Surname First Name(s) Route to current team concatenated
0 10604 JONES AMY LOAN JONESAMY
1 12885 KING HELEN TRANSFER KINGHELEN
我正在努力修改这部电影
到当前团队的路线
因此,生成的更新后的rawReturn数据帧如下所示:
Identifier Entry Date Route to current team concatenated
0 12884 .. 01/01/2012 TRANSFER SMITHROBERT
1 10604 .. 04/07/2013 LOAN JONESAMY
2 14445 .. 16/07/2018 EXTERNAL EVANSSTEVEN
3 7898 .. 03/09/2010 LOAN HILLEMMA
: : .. : : :
34578 10487 .. 01/07/2012 TRANSFER DENSMARCUS
34579 13016 .. 02/06/2014 EXTERNAL WHITECHRIS
34580 12885 .. 09/08/2016 LOAN COLESDAVID
34581 .. 05/08/2014 TRANSFER KINGHELEN
header = df.columns
for item in header[3:]:
if item != 'concatenated':
rawReturn.loc[rawReturn.concatenated.isin(df.concatenated),[item]] = df[item]
在上面我有一个变量叫做
item
项目
将设置为
到当前团队的路线
)价值
原始收益
如果
concatenated
测向
.
当前返回的输出是:
Identifier Entry Date Route to current team concatenated
0 12884 .. 01/01/2012 TRANSFER SMITHROBERT
1 10604 .. 04/07/2013 JONESAMY
2 14445 .. 16/07/2018 EXTERNAL EVANSSTEVEN
3 7898 .. 03/09/2010 LOAN HILLEMMA
: : .. : : :
34578 10487 .. 01/07/2012 TRANSFER DENSMARCUS
34579 13016 .. 02/06/2014 EXTERNAL WHITECHRIS
34580 12885 .. 09/08/2016 LOAN COLESDAVID
34581 .. 05/08/2014 KINGHELEN
在这个例子中,Amy和Helen在
列(在df数据帧中有更新)已被删除且未更新。
我做错了什么?