def mean_of_first_n_matches(df, var, n):
    """Computes for each player the mean of variable var for the first n matches and returns means as a list"""
    players = df.groupby('account_id', sort=False)
    means = players.apply(lambda x: x[var].head(n).mean()).tolist()
    
    return means