我有这个{
rank player_id posicao
0 39 82730 Goleiro
1 136 100651 Atacante
2 140 87863 Meio-Campista
3 66 83257 Atacante
4 139 101290 Atacante
df_players.info()
:
Data columns (total 3 columns):
rank 733 non-null int64
player_id 733 non-null int64
posicao 733 non-null object
dtypes: int64(2), object(1)
我有这个{
jogo_id rodada_id time_id time_nome adversario_id adversario_nome ... preco_num variacao_num media_num jogos_num status ano
0 232423 1 293.0 Athletico-PR 267 Vasco ... 2.00 0.00 0.0 0 Nulo 2019
1 232423 1 293.0 Athletico-PR 267 Vasco ... 4.00 0.00 0.0 0 Nulo 2019
2 232423 1 293.0 Athletico-PR 267 Vasco ... 2.00 0.00 0.0 0 Nulo 2019
3 232423 1 293.0 Athletico-PR 267 Vasco ... 2.00 0.00 0.0 0 Nulo 2019
4 232423 1 293.0 Athletico-PR 267 Vasco ... 5.83 -2.17 0.4 1 Nulo 2019
df_games.info()
:
Data columns (total 19 columns):
...
player_id 30042 non-null int64
...
dtypes: float64(7), int64(7), object(5)
现在我尝试使用两个dfs上的“player_id”将rank
值从df_players
传递到df_games
,如下所示:
df_games['rank'] = df_games['atleta_id'].map(df_players['rank'])
但所有级别都在操作后打印NaN
我错过了什么
您就快到了,只需在
map
中添加set_index()
更具可读性的方式
您可以使用pd.merge从df_游戏中获得排名
您还可以从pandas的文档中查看更多详细信息
相关问题 更多 >
编程相关推荐