I have a database where four of its columns are: score_home, score_away, home_id and away_id.
I expect to get a variable whose rows contain the winning ID in each game.
Index | gRes |
---|---|
0 | GB |
1 | GB |
For that, I tried with the following code
team_f['gRes'] = 0
if team_f['score_home'] > team_f['score_away']:
team_f['gRes'] = team_f['home_id']
else:
team_f['gRes'] = team_f['away_id']
and i get the following error
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Could you suggest how to correct the error or, failing that, any alternatives to build the variable?