def calc_points(goals, assists):
    """
    Calculate the total traditional and weighted points for all
    players, grouped by player id.
    
    Author: Rasmus Säfvenberg
    
    Parameters
    ----------
    goals : pandas.DataFrame
        A data frame with total goals and weighted assists per player.
    assists : pandas.DataFrame
        A data frame with total assists and weighted assists per player.

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

    """
       
    # Specify columns to keep for merging
    goals = goals[["PlayerId", "PlayerName", "Position", "Goals", "WeightedGoals"]]
    assists = assists[["PlayerId", "PlayerName", "Position", "Assists", "WeightedAssists"]]
    
    # Combine goals and assists
    points = goals.merge(assists, on=["PlayerId", "PlayerName", "Position"], 
                         how="outer")
    
    # Fill missing values with 0 (some players only score goals etc.)
    points.fillna(0, inplace=True)
    
    # Calculate points = goals + assists
    points["Points"] = points["Goals"] + points["Assists"]
    
    # Calculate weighted points = weighted goals + weighted assists
    points["WeightedPoints"] = points["WeightedGoals"] + points["WeightedAssists"]

    # Sort by weighted points
    points.sort_values("WeightedPoints", ascending=False, inplace=True)
    
    return points