我正在尝试合并 2 个数据帧,但由于某种原因它抛出KeyError: Player_Id
我正在尝试合并Striker_Id
and Player_Id
这就是我的数据框的样子
合并代码:
player_runs.merge(matches_played_by_players,left_on='Striker_Id',right_on='Player_Id',how='left')
我究竟做错了什么?
嗯,从你的问题来看,你似乎正在尝试合并索引,但你将它们视为列?尝试稍微改变一下你的合并代码 -
player_runs.merge(matches_played_by_players,
left_index=True,
right_index=True,
how='left')
Furthermore, make sure that both indexes are of the same type (in this case, consider str
int
?)
player_runs.index = player_runs.index.astype(int)
And,
matches_played_by_players.index = matches_played_by_players.index.astype(int)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)