Skip to content

Commit

Permalink
Expected points columns for future game weeks are incorrect in player…
Browse files Browse the repository at this point in the history
…_gw_next_eps_ext and players_gw_team_eps_ext (#21)

Expected points columns for future game weeks are incorrect in player_gw_next_eps_ext and players_gw_team_eps_ext
  • Loading branch information
177arc authored Jan 4, 2021
1 parent 6160c67 commit cb31045
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 65 deletions.
7 changes: 5 additions & 2 deletions fpldata/derive.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ def get_team_fixture_strength(fixture_teams_stats: DF, teams: DF, ctx: Context)
def get_player_team_fixture_strength(players: DF, team_fixture_strength: DF, players_history: DF, ctx: Context) -> DF:
def roll_sum_back(df: DF, group_by: str, col: str, ctx: Context):
return (df.groupby(group_by)
[col].apply(lambda x: x.rolling(ctx.player_fixtures_look_back, min_periods=1).sum()))
[col].apply(lambda x: x.rolling(ctx.player_fixtures_look_back, min_periods=1).sum())
.where((df['Season'] == ctx.current_season) & (df['Game Week'] <= ctx.next_gw) | (df['Season'] != ctx.current_season)))

return (players[['Name', 'Player Team Code', 'Field Position']]
.reset_index()
Expand Down Expand Up @@ -420,7 +421,9 @@ def roll_sum_back(df: DF, group_by: str, col: str, ctx: Context):
df['_Rel Clean Sheet Fixture Strength Home'],
df['_Rel Clean Sheet Fixture Strength Away'])})
.assign(**{'Stats Completeness Percent': lambda df: df['Fixtures Played To Fixture'] / ctx.player_fixtures_look_back * 100})
.assign(**{'Rolling Avg Game Points': lambda df: df.groupby('Player Code')['Fixture Total Points'].apply(lambda x: x.rolling(ctx.player_fixtures_look_back, min_periods=1).mean())})

.assign(**{'Rolling Avg Game Points': lambda df: df.groupby('Player Code')['Fixture Total Points'].apply(lambda x: x.rolling(ctx.player_fixtures_look_back, min_periods=1).mean())
.where((df['Season'] == ctx.current_season) & (df['Game Week'] <= ctx.next_gw) | (df['Season'] != ctx.current_season))})
.drop(columns=['Fixture Minutes Played', 'Fixture Total Points', 'Fixture Played']))


Expand Down
108 changes: 54 additions & 54 deletions prep_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:27.089199Z",
"start_time": "2021-01-04T21:23:27.075200Z"
"end_time": "2021-01-04T23:25:21.824005Z",
"start_time": "2021-01-04T23:25:21.810007Z"
}
},
"outputs": [],
Expand All @@ -35,8 +35,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:29.211922Z",
"start_time": "2021-01-04T21:23:27.091200Z"
"end_time": "2021-01-04T23:25:23.931003Z",
"start_time": "2021-01-04T23:25:21.826010Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -77,8 +77,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:29.226923Z",
"start_time": "2021-01-04T21:23:29.213923Z"
"end_time": "2021-01-04T23:25:23.947004Z",
"start_time": "2021-01-04T23:25:23.933005Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -132,8 +132,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:29.258921Z",
"start_time": "2021-01-04T21:23:29.228924Z"
"end_time": "2021-01-04T23:25:23.979003Z",
"start_time": "2021-01-04T23:25:23.949007Z"
}
},
"outputs": [],
Expand All @@ -160,8 +160,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:30.580282Z",
"start_time": "2021-01-04T21:23:29.260925Z"
"end_time": "2021-01-04T23:25:25.316004Z",
"start_time": "2021-01-04T23:25:23.981005Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -190,8 +190,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:30.884296Z",
"start_time": "2021-01-04T21:23:30.582283Z"
"end_time": "2021-01-04T23:25:25.607003Z",
"start_time": "2021-01-04T23:25:25.317005Z"
}
},
"outputs": [],
Expand All @@ -208,8 +208,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:30.931294Z",
"start_time": "2021-01-04T21:23:30.890297Z"
"end_time": "2021-01-04T23:25:25.670004Z",
"start_time": "2021-01-04T23:25:25.613006Z"
}
},
"outputs": [],
Expand All @@ -235,8 +235,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:31.289013Z",
"start_time": "2021-01-04T21:23:30.933297Z"
"end_time": "2021-01-04T23:25:26.034003Z",
"start_time": "2021-01-04T23:25:25.672006Z"
}
},
"outputs": [],
Expand All @@ -253,8 +253,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:31.336015Z",
"start_time": "2021-01-04T21:23:31.291016Z"
"end_time": "2021-01-04T23:25:26.098005Z",
"start_time": "2021-01-04T23:25:26.036006Z"
}
},
"outputs": [],
Expand All @@ -281,8 +281,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:46.047107Z",
"start_time": "2021-01-04T21:23:31.338018Z"
"end_time": "2021-01-04T23:25:40.850093Z",
"start_time": "2021-01-04T23:25:26.100006Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -311,8 +311,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:46.269110Z",
"start_time": "2021-01-04T21:23:46.049110Z"
"end_time": "2021-01-04T23:25:41.103093Z",
"start_time": "2021-01-04T23:25:40.852096Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -347,8 +347,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:46.284108Z",
"start_time": "2021-01-04T21:23:46.271110Z"
"end_time": "2021-01-04T23:25:41.118094Z",
"start_time": "2021-01-04T23:25:41.105097Z"
}
},
"outputs": [],
Expand All @@ -368,8 +368,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:46.332108Z",
"start_time": "2021-01-04T21:23:46.286109Z"
"end_time": "2021-01-04T23:25:41.166093Z",
"start_time": "2021-01-04T23:25:41.120095Z"
}
},
"outputs": [],
Expand All @@ -390,8 +390,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:46.348110Z",
"start_time": "2021-01-04T21:23:46.334109Z"
"end_time": "2021-01-04T23:25:41.198102Z",
"start_time": "2021-01-04T23:25:41.168095Z"
}
},
"outputs": [],
Expand All @@ -412,8 +412,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:47.206112Z",
"start_time": "2021-01-04T21:23:46.350110Z"
"end_time": "2021-01-04T23:25:42.068094Z",
"start_time": "2021-01-04T23:25:41.200095Z"
}
},
"outputs": [],
Expand All @@ -433,8 +433,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:47.284109Z",
"start_time": "2021-01-04T21:23:47.208112Z"
"end_time": "2021-01-04T23:25:42.177093Z",
"start_time": "2021-01-04T23:25:42.070094Z"
}
},
"outputs": [],
Expand All @@ -457,8 +457,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:47.314107Z",
"start_time": "2021-01-04T21:23:47.285109Z"
"end_time": "2021-01-04T23:25:42.209097Z",
"start_time": "2021-01-04T23:25:42.179098Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -519,8 +519,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:47.565108Z",
"start_time": "2021-01-04T21:23:47.316110Z"
"end_time": "2021-01-04T23:25:42.480096Z",
"start_time": "2021-01-04T23:25:42.211095Z"
}
},
"outputs": [],
Expand All @@ -541,8 +541,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:54.503213Z",
"start_time": "2021-01-04T21:23:47.567112Z"
"end_time": "2021-01-04T23:25:49.469097Z",
"start_time": "2021-01-04T23:25:42.482095Z"
},
"scrolled": false
},
Expand All @@ -564,8 +564,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:55.249214Z",
"start_time": "2021-01-04T21:23:54.505215Z"
"end_time": "2021-01-04T23:25:50.198094Z",
"start_time": "2021-01-04T23:25:49.471097Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -601,8 +601,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:23:56.308785Z",
"start_time": "2021-01-04T21:23:55.253220Z"
"end_time": "2021-01-04T23:25:51.240094Z",
"start_time": "2021-01-04T23:25:50.201099Z"
}
},
"outputs": [],
Expand All @@ -622,8 +622,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:24:07.379839Z",
"start_time": "2021-01-04T21:23:56.310787Z"
"end_time": "2021-01-04T23:26:02.248409Z",
"start_time": "2021-01-04T23:25:51.242095Z"
}
},
"outputs": [],
Expand All @@ -648,8 +648,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:24:41.407769Z",
"start_time": "2021-01-04T21:24:07.381843Z"
"end_time": "2021-01-04T23:26:36.129974Z",
"start_time": "2021-01-04T23:26:02.250412Z"
}
},
"outputs": [],
Expand All @@ -669,8 +669,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:24:41.581771Z",
"start_time": "2021-01-04T21:24:41.409774Z"
"end_time": "2021-01-04T23:26:36.304972Z",
"start_time": "2021-01-04T23:26:36.132978Z"
}
},
"outputs": [],
Expand All @@ -690,8 +690,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:24:44.576796Z",
"start_time": "2021-01-04T21:24:41.583772Z"
"end_time": "2021-01-04T23:26:39.364972Z",
"start_time": "2021-01-04T23:26:36.306974Z"
}
},
"outputs": [],
Expand All @@ -706,8 +706,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:24:44.592797Z",
"start_time": "2021-01-04T21:24:44.578797Z"
"end_time": "2021-01-04T23:26:39.379973Z",
"start_time": "2021-01-04T23:26:39.366975Z"
}
},
"outputs": [],
Expand All @@ -732,8 +732,8 @@
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2021-01-04T21:25:01.497776Z",
"start_time": "2021-01-04T21:24:44.594801Z"
"end_time": "2021-01-04T23:26:56.711211Z",
"start_time": "2021-01-04T23:26:39.381974Z"
}
},
"outputs": [],
Expand Down
Loading

0 comments on commit cb31045

Please sign in to comment.