def calc_goals(data):
    """
    Calculate the total traditional and weighted goals for all
    players, grouped by player id.
    
    Author: Rasmus Säfvenberg

    Parameters
    ----------
    data : pandas.DataFrame
        A data frame as retrieved by weighted.get_data()

    Returns
    -------
    weighted_goals : pandas.DataFrame
        A data frame with total goals and weighted goals per player.

    """  
    # Get required columns
    goals = data[["GoalScorerId", "reward"]].copy()
    
    # Intialize new columns that means 1 goal per event.
    goals["GoalsScored"] = 1
    
    # Calculate number of goals and weighted goals per player
    weighted_goals = goals.groupby("GoalScorerId")[["GoalsScored", "reward"]].sum().reset_index().\
                          rename(columns={"GoalsScored": "Goals", 
                                          "reward": "WeightedGoals", 
                                          "GoalScorerId": "PlayerId"}).\
                              sort_values("WeightedGoals", ascending=False)
                              
    return weighted_goals