I have this dataset:
df = pd.DataFrame({'game_id' : [123,123,456,456],
'location' : ['home', 'away','home', 'away'],
'away_team' : ['braves', 'braves', 'mets', 'mets'],
'home_team' : ['phillies', 'phillies', 'marlins', 'marlins']})
I want to transform it so that the away_team and home_team columns are collapsed into 1 "team" column that aligns with location, for each "game_id". I would want it to look like this: