我有这个示例数据集:
HOME_TEAM AWAY_TEAM TIMES
0 Argentina Uruguay 3
1 Uruguay Argentina 5
我想了解这支球队在其中所经历的时间。
Matches TIMES
3 Argentina-Uruguay 8
我一直在尝试以下代码:
af = af.merge(
af,
left_on=["home_team", "away_team"],
right_on=["away_team", "home_team"],
how='left'
)
输出是:
home_team_x away_team_y values_x home_team_y away_team_y values_y
0 Argentina Uruguay 96 Uruguay Argentina 80.0
1 Uruguay Argentina 80 Argentina Uruguay 96.0
有没有一种方法可以以Python方式实现并避免重复?
元芳怎么了
相关分类