I have a DataFrame like this:
Team      Player      Goals       YellowCards          RedCards
Team1     Player1       2             1                    1
Team1     Player2       3             1                    0
Team2     Player3       2             2                    1
I'm trying to calculate sum of Goals, YellowCards and RedCards for each team and create new dataframe for result. I have tried:
pd.crosstab(df['Team'],[df['Goals'],df['YellowCards'],df['RedCards']], aggfunc='sum')
But it's not working. Preferably I would like to do this with either crosstab or pivot_table function. Any advise is highly appreciated.
 
     
    