def calc_first_assists(data):
    """
    Calculate the total traditional and weighted first assist 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_first_assists : pandas.DataFrame
        A data frame with total and weighted first assists per player.

    """
    
    # Get required columns
    first_assists = data[["FirstAssistId", "reward"]].copy()
    
    # Convert from wide to long and have each assist (first only) as a row
    first_assists = first_assists.rename(columns={"FirstAssistId": "AssistId"}).\
        melt(id_vars="reward").\
        rename(columns={"value": "PlayerId"}).drop("variable", axis=1)
    
    # Intialize new columns that means 1 assist per event.
    first_assists["AssistedGoals"] = 1
    
    # Calculate number of assists and weighted assists per player
    weighted_first_assists = first_assists.groupby("PlayerId")[["AssistedGoals", "reward"]].\
        sum().reset_index().rename(columns={"AssistedGoals": "First_Assists", 
                                            "reward": "WeightedFirst_Assists"}).\
                              sort_values("WeightedFirst_Assists", ascending=False)
                              
    return weighted_first_assists