I am trying to iterate through some dataframe values, and populate an empty column as I do it, like so:
df_team_matches['Result'] = ""
results = []
for row in df_team_matches.itertuples():
goals = row.Goals
conceded = row.GoalsConceded
if goals > conceded:
result = 'win'
results.append(result)
elif goals < conceded:
result = 'defeat'
results.append(result)
elif goals == conceded:
result = 'draw'
results.append(result)
df_team_matches['Result'] = results
The above works, but it seems to my a bit cumbersome.
Is there a cleaner, faster way of achieving the same result using some pandas
method?