I have a dataframe of games played by different number of players for each game. Simplified, it looks like this:
GameID Player Score
------ ------ -----
1      John   10
1      Alice  20
1      Bob    30
2      John   15
2      Alice  25
I'm trying to display the dataframe of the winner of each game but I'm having trouble with the syntax after using groupby. I managed to get a Series or a Dataframe of the rows with the highest score in each game by doing either of these:
df.groupby('GameID')['Score'].max()
df.groupby('GameID').aggregate({'Score': max})
But I'd like to display the entire dataframe, including the Player column (as well as other columns present in the dataframe, which I've simplified here).
What is the correct way to do this?
