rank = pd.merge(home.set_index("home_team_api_id").rename_axis("team_api_id"),
away.set_index("away_team_api_id").rename_axis("team_api_id"),
on="team_api_id")
rank["total_points"] = rank["home_points"] + rank["away_points"]
>>> rank
home_points away_points total_points
team_api_id
262 37 34 71
263 14 13 27
264 31 20 51
265 29 15 44
266 38 26 64
267 26 15 41
275 35 23 58
276 37 29 66
277 34 20 54
280 35 18 53
282 46 22 68
284 36 23 59
285 41 29 70
290 23 14 37
292 26 16 42
293 32 21 53
294 18 13 31
354 26 26 52
356 30 11 41
373 27 23 50
奖金
:排名
rank["rank"] = rank["total_points"].rank(method="max", ascending=False).astype(int)
>>> rank.sort_values("rank")
home_points away_points total_points rank
team_api_id
262 37 34 71 1
285 41 29 70 2
282 46 22 68 3
276 37 29 66 4
266 38 26 64 5
284 36 23 59 6
275 35 23 58 7
277 34 20 54 8
293 32 21 53 10
280 35 18 53 10
354 26 26 52 11
264 31 20 51 12
373 27 23 50 13
265 29 15 44 14
292 26 16 42 15
267 26 15 41 17
356 30 11 41 17
290 23 14 37 18
294 18 13 31 19
263 14 13 27 20