Q:

Pandas - mean() on a weekly basis

With:
df_temp = df_players[['Player', 'GameWeek', 'Goals]]
df_temp = df_temp[df_temp['Player'] == 'Sergio Aguero']

This is how dataframe looks like:
              Player  GameWeek  Goals
236    Sergio Aguero         1      1
769    Sergio Aguero         2      1
1584   Sergio Aguero         3      2
1915   Sergio Aguero         4      2
2417   Sergio Aguero         5      1
2978   Sergio Aguero         6      1
3604   Sergio Aguero         7      0
4369   Sergio Aguero         8      0
4724   Sergio Aguero         9      0
5282   Sergio Aguero        10      0
5826   Sergio Aguero        11      1
6674   Sergio Aguero        12      0
7000   Sergio Aguero        13      0
7481   Sergio Aguero        14      0
7962   Sergio Aguero        15      0
8605   Sergio Aguero        16      0
9398   Sergio Aguero        17      0
9786   Sergio Aguero        18      0
10578  Sergio Aguero        19      0
11112  Sergio Aguero        20      1
11438  Sergio Aguero        21      0
12262  Sergio Aguero        22      3
12513  Sergio Aguero        23      2
13075  Sergio Aguero        24      1
13947  Sergio Aguero        25      0
14507  Sergio Aguero        26      0
14753  Sergio Aguero        27      0

know I can get the 'Goals' mean for the player with:
df_temp['Goals'].mean()
But how do I add a new 'Mean' column where mean value is calculated per 'GameWeek'?
For instance:
              Player  GameWeek  Goals  Means
236    Sergio Aguero         1      1    1.0
769    Sergio Aguero         2      1    1.0
1584   Sergio Aguero         3      2    1.33

And so on. 

A:

I think you want expanding with mean like
df_temp['exp_mean'] = df_temp['Goals'].expanding().mean()
print (df_temp)
               Player  GameWeek  Goals  exp_mean
236    Sergio  Aguero         1      1  1.000000
769    Sergio  Aguero         2      1  1.000000
1584   Sergio  Aguero         3      2  1.333333
1915   Sergio  Aguero         4      2  1.500000
2417   Sergio  Aguero         5      1  1.400000
2978   Sergio  Aguero         6      1  1.333333
3604   Sergio  Aguero         7      0  1.142857
4369   Sergio  Aguero         8      0  1.000000
4724   Sergio  Aguero         9      0  0.888889
5282   Sergio  Aguero        10      0  0.800000
5826   Sergio  Aguero        11      1  0.818182
6674   Sergio  Aguero        12      0  0.750000
7000   Sergio  Aguero        13      0  0.692308
7481   Sergio  Aguero        14      0  0.642857
7962   Sergio  Aguero        15      0  0.600000
8605   Sergio  Aguero        16      0  0.562500
9398   Sergio  Aguero        17      0  0.529412
9786   Sergio  Aguero        18      0  0.500000
10578  Sergio  Aguero        19      0  0.473684
11112  Sergio  Aguero        20      1  0.500000
11438  Sergio  Aguero        21      0  0.476190
12262  Sergio  Aguero        22      3  0.590909
12513  Sergio  Aguero        23      2  0.652174
13075  Sergio  Aguero        24      1  0.666667
13947  Sergio  Aguero        25      0  0.640000
14507  Sergio  Aguero        26      0  0.615385
14753  Sergio  Aguero        27      0  0.592593

