{ "cells": [ { "cell_type": "markdown", "id": "8f597771", "metadata": {}, "source": [ "Player/match dataset creation\n", "\n", "For each serie A (already happened) match and player, a database entry is generated, with this form:\n", " \n", "[y = player votes data, player data, team data, vs team data, opp team data, vs opp team data]" ] }, { "cell_type": "code", "execution_count": 50, "id": "3ecf3676", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "id": "a7d3a9d6", "metadata": {}, "source": [ "Load team data from FBref" ] }, { "cell_type": "code", "execution_count": 51, "id": "8a6867a5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_5880\\552672520.py:19: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " team_data['team_idx'][i] = team_data['team_idx'][i].split(' ')[-1]\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
teamteam_players_usedteam_possessionteam_gamesteam_games_startsteam_minutesteam_goalsteam_assiststeam_pens_madeteam_pens_att...vs_team_foulsvs_team_fouledvs_team_offsidesvs_team_pens_wonvs_team_pens_concededvs_team_own_goalsvs_team_ball_recoveriesvs_team_aerials_wonvs_team_aerials_lostvs_team_aerials_won_pct
team_idx
AtalantaAtalanta24.049.120.0220.01800.038.027.06.08.0...220.0232.026.01.08.01.01214.0248.0303.045.0
BolognaBologna24.052.620.0220.01800.025.019.03.03.0...252.0229.033.03.03.01.01081.0224.0180.055.4
CremoneseCremonese29.043.620.0220.01800.015.07.02.04.0...217.0254.032.03.04.00.01106.0367.0273.057.3
EmpoliEmpoli26.046.420.0220.01800.019.011.00.00.0...260.0226.032.02.00.00.01062.0231.0203.053.2
FiorentinaFiorentina27.057.120.0220.01800.022.017.02.04.0...271.0243.053.01.04.00.01005.0261.0302.046.4
VeronaHellas Verona32.043.520.0220.01800.016.013.00.00.0...201.0286.022.01.00.02.01096.0362.0411.046.8
InterInter23.053.620.0220.01800.039.026.02.02.0...249.0224.018.02.02.01.0914.0204.0251.044.8
JuventusJuventus26.049.420.0220.01800.030.023.02.03.0...220.0221.027.00.03.00.01007.0240.0247.049.3
LazioLazio21.050.920.0220.01800.035.025.03.04.0...278.0196.044.01.04.01.01085.0196.0193.050.4
LecceLecce26.042.520.0220.01800.018.012.01.02.0...263.0265.043.03.02.01.01072.0373.0295.055.8
MilanMilan27.054.820.0220.01800.035.030.02.02.0...242.0237.023.04.02.02.01005.0234.0288.044.8
MonzaMonza29.055.120.0220.01800.024.015.03.03.0...291.0251.037.00.03.01.01023.0214.0225.048.7
NapoliNapoli24.061.020.0220.01800.048.039.04.05.0...272.0174.027.01.04.00.0995.0210.0244.046.3
RomaRoma25.049.120.0220.01800.026.017.03.05.0...274.0228.010.00.05.00.01048.0197.0234.045.7
SalernitanaSalernitana28.044.820.0220.01800.024.016.01.01.0...226.0233.049.07.01.01.01084.0258.0240.051.8
SampdoriaSampdoria30.048.920.0220.01800.08.07.00.00.0...316.0277.056.03.00.00.01075.0324.0327.049.8
SassuoloSassuolo27.048.320.0220.01800.023.017.04.05.0...262.0190.067.02.05.00.01043.0229.0183.055.6
SpeziaSpezia30.046.720.0220.01800.015.010.02.02.0...207.0261.046.01.02.02.01182.0322.0281.053.4
TorinoTorino24.052.920.0220.01800.021.016.01.01.0...221.0274.022.03.01.00.01045.0337.0309.052.2
UdineseUdinese23.050.420.0220.01800.027.023.00.00.0...261.0235.031.02.00.01.01010.0212.0254.045.5
\n", "

20 rows × 321 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 24.0 49.1 20.0 \n", "Bologna Bologna 24.0 52.6 20.0 \n", "Cremonese Cremonese 29.0 43.6 20.0 \n", "Empoli Empoli 26.0 46.4 20.0 \n", "Fiorentina Fiorentina 27.0 57.1 20.0 \n", "Verona Hellas Verona 32.0 43.5 20.0 \n", "Inter Inter 23.0 53.6 20.0 \n", "Juventus Juventus 26.0 49.4 20.0 \n", "Lazio Lazio 21.0 50.9 20.0 \n", "Lecce Lecce 26.0 42.5 20.0 \n", "Milan Milan 27.0 54.8 20.0 \n", "Monza Monza 29.0 55.1 20.0 \n", "Napoli Napoli 24.0 61.0 20.0 \n", "Roma Roma 25.0 49.1 20.0 \n", "Salernitana Salernitana 28.0 44.8 20.0 \n", "Sampdoria Sampdoria 30.0 48.9 20.0 \n", "Sassuolo Sassuolo 27.0 48.3 20.0 \n", "Spezia Spezia 30.0 46.7 20.0 \n", "Torino Torino 24.0 52.9 20.0 \n", "Udinese Udinese 23.0 50.4 20.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 220.0 1800.0 38.0 27.0 \n", "Bologna 220.0 1800.0 25.0 19.0 \n", "Cremonese 220.0 1800.0 15.0 7.0 \n", "Empoli 220.0 1800.0 19.0 11.0 \n", "Fiorentina 220.0 1800.0 22.0 17.0 \n", "Verona 220.0 1800.0 16.0 13.0 \n", "Inter 220.0 1800.0 39.0 26.0 \n", "Juventus 220.0 1800.0 30.0 23.0 \n", "Lazio 220.0 1800.0 35.0 25.0 \n", "Lecce 220.0 1800.0 18.0 12.0 \n", "Milan 220.0 1800.0 35.0 30.0 \n", "Monza 220.0 1800.0 24.0 15.0 \n", "Napoli 220.0 1800.0 48.0 39.0 \n", "Roma 220.0 1800.0 26.0 17.0 \n", "Salernitana 220.0 1800.0 24.0 16.0 \n", "Sampdoria 220.0 1800.0 8.0 7.0 \n", "Sassuolo 220.0 1800.0 23.0 17.0 \n", "Spezia 220.0 1800.0 15.0 10.0 \n", "Torino 220.0 1800.0 21.0 16.0 \n", "Udinese 220.0 1800.0 27.0 23.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls \\\n", "team_idx ... \n", "Atalanta 6.0 8.0 ... 220.0 \n", "Bologna 3.0 3.0 ... 252.0 \n", "Cremonese 2.0 4.0 ... 217.0 \n", "Empoli 0.0 0.0 ... 260.0 \n", "Fiorentina 2.0 4.0 ... 271.0 \n", "Verona 0.0 0.0 ... 201.0 \n", "Inter 2.0 2.0 ... 249.0 \n", "Juventus 2.0 3.0 ... 220.0 \n", "Lazio 3.0 4.0 ... 278.0 \n", "Lecce 1.0 2.0 ... 263.0 \n", "Milan 2.0 2.0 ... 242.0 \n", "Monza 3.0 3.0 ... 291.0 \n", "Napoli 4.0 5.0 ... 272.0 \n", "Roma 3.0 5.0 ... 274.0 \n", "Salernitana 1.0 1.0 ... 226.0 \n", "Sampdoria 0.0 0.0 ... 316.0 \n", "Sassuolo 4.0 5.0 ... 262.0 \n", "Spezia 2.0 2.0 ... 207.0 \n", "Torino 1.0 1.0 ... 221.0 \n", "Udinese 0.0 0.0 ... 261.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 232.0 26.0 1.0 \n", "Bologna 229.0 33.0 3.0 \n", "Cremonese 254.0 32.0 3.0 \n", "Empoli 226.0 32.0 2.0 \n", "Fiorentina 243.0 53.0 1.0 \n", "Verona 286.0 22.0 1.0 \n", "Inter 224.0 18.0 2.0 \n", "Juventus 221.0 27.0 0.0 \n", "Lazio 196.0 44.0 1.0 \n", "Lecce 265.0 43.0 3.0 \n", "Milan 237.0 23.0 4.0 \n", "Monza 251.0 37.0 0.0 \n", "Napoli 174.0 27.0 1.0 \n", "Roma 228.0 10.0 0.0 \n", "Salernitana 233.0 49.0 7.0 \n", "Sampdoria 277.0 56.0 3.0 \n", "Sassuolo 190.0 67.0 2.0 \n", "Spezia 261.0 46.0 1.0 \n", "Torino 274.0 22.0 3.0 \n", "Udinese 235.0 31.0 2.0 \n", "\n", " vs_team_pens_conceded vs_team_own_goals \\\n", "team_idx \n", "Atalanta 8.0 1.0 \n", "Bologna 3.0 1.0 \n", "Cremonese 4.0 0.0 \n", "Empoli 0.0 0.0 \n", "Fiorentina 4.0 0.0 \n", "Verona 0.0 2.0 \n", "Inter 2.0 1.0 \n", "Juventus 3.0 0.0 \n", "Lazio 4.0 1.0 \n", "Lecce 2.0 1.0 \n", "Milan 2.0 2.0 \n", "Monza 3.0 1.0 \n", "Napoli 4.0 0.0 \n", "Roma 5.0 0.0 \n", "Salernitana 1.0 1.0 \n", "Sampdoria 0.0 0.0 \n", "Sassuolo 5.0 0.0 \n", "Spezia 2.0 2.0 \n", "Torino 1.0 0.0 \n", "Udinese 0.0 1.0 \n", "\n", " vs_team_ball_recoveries vs_team_aerials_won \\\n", "team_idx \n", "Atalanta 1214.0 248.0 \n", "Bologna 1081.0 224.0 \n", "Cremonese 1106.0 367.0 \n", "Empoli 1062.0 231.0 \n", "Fiorentina 1005.0 261.0 \n", "Verona 1096.0 362.0 \n", "Inter 914.0 204.0 \n", "Juventus 1007.0 240.0 \n", "Lazio 1085.0 196.0 \n", "Lecce 1072.0 373.0 \n", "Milan 1005.0 234.0 \n", "Monza 1023.0 214.0 \n", "Napoli 995.0 210.0 \n", "Roma 1048.0 197.0 \n", "Salernitana 1084.0 258.0 \n", "Sampdoria 1075.0 324.0 \n", "Sassuolo 1043.0 229.0 \n", "Spezia 1182.0 322.0 \n", "Torino 1045.0 337.0 \n", "Udinese 1010.0 212.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 303.0 45.0 \n", "Bologna 180.0 55.4 \n", "Cremonese 273.0 57.3 \n", "Empoli 203.0 53.2 \n", "Fiorentina 302.0 46.4 \n", "Verona 411.0 46.8 \n", "Inter 251.0 44.8 \n", "Juventus 247.0 49.3 \n", "Lazio 193.0 50.4 \n", "Lecce 295.0 55.8 \n", "Milan 288.0 44.8 \n", "Monza 225.0 48.7 \n", "Napoli 244.0 46.3 \n", "Roma 234.0 45.7 \n", "Salernitana 240.0 51.8 \n", "Sampdoria 327.0 49.8 \n", "Sassuolo 183.0 55.6 \n", "Spezia 281.0 53.4 \n", "Torino 309.0 52.2 \n", "Udinese 254.0 45.5 \n", "\n", "[20 rows x 321 columns]" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rcsv = pd.read_csv('fbref_data/teams.csv') \n", "team = pd.DataFrame(rcsv)\n", "\n", "rcsv = pd.read_csv('fbref_data/teams_vs.csv') \n", "vs_team = pd.DataFrame(rcsv)\n", "\n", "for i in range(1, team.shape[1]):\n", " team = team.rename(columns = {team.columns[i] : 'team_' + team.columns[i]})\n", " \n", "for i in range(1, vs_team.shape[1]):\n", " vs_team = vs_team.rename(columns = {vs_team.columns[i] : 'vs_team_' + vs_team.columns[i]})\n", " \n", "vs_team.pop('team')\n", "\n", "team_data = pd.concat([team, vs_team], axis = 1)\n", "\n", "team_data['team_idx'] = team_data['team']\n", "for i in range(team_data.shape[0]):\n", " team_data['team_idx'][i] = team_data['team_idx'][i].split(' ')[-1]\n", "\n", "team_data = team_data.set_index('team_idx')\n", "\n", "team_data\n", "\n" ] }, { "cell_type": "code", "execution_count": 52, "id": "b6a3db98", "metadata": {}, "outputs": [], "source": [ "team_data.to_excel('mid_outputs/team_data.xlsx')" ] }, { "cell_type": "markdown", "id": "cc50dde9", "metadata": {}, "source": [ "Load data generated from players_dataset_creation" ] }, { "cell_type": "code", "execution_count": 53, "id": "c34eb398", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0idrteamsurnameinitialfb_IDagebirth_yeargames...gk_pct_goal_kicks_launchedgk_goal_kick_length_avggk_crossesgk_crosses_stoppedgk_crosses_stopped_pctgk_def_actions_outside_pen_areagk_def_actions_outside_pen_area_per90gk_avg_distance_def_actionsvote_avgvote_std
name
Meret0572PNapoliMeretNaN53525-31919970...20.327.5213.06.02.824.01.2017.26.2750000.486698
Provedel12814PLazioProvedelNaN54428-32419940...33.634.2266.07.02.637.01.8618.06.2250000.334477
Vicario24964PEmpoliVicarioNaN55326-12019960...47.742.5412.025.06.110.00.5010.76.4500000.384057
Szczesny3453PJuventusSzczesnyNaN55032-29219900...40.338.9159.04.02.510.00.7415.16.0357140.351745
Falcone42134PLecceFalconeNaN53027-29819950...75.051.4302.013.04.320.01.0012.56.3250000.363146
..................................................................
De Luca5385512ASampdoriaLucaNaN13024-20219981...0.00.00.00.00.00.00.000.05.8816600.665426
Voelkerling Persson5395837ALeccePerssonNaN49420-02020032...0.00.00.00.00.00.00.000.06.2274920.259439
Montevago5406113ASampdoriaMontevagoNaN32219-32320036...0.00.00.00.00.00.00.000.05.9562910.615163
Krollis5416143ASpeziaKrollisNaN-1000...0.00.00.00.00.00.00.000.05.6995620.705829
Vivaldo5426160AUdineseVivaldoNaN-1000...0.00.00.00.00.00.00.000.05.8881110.648879
\n", "

543 rows × 169 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID \\\n", "name \n", "Meret 0 572 P Napoli Meret NaN 535 \n", "Provedel 1 2814 P Lazio Provedel NaN 544 \n", "Vicario 2 4964 P Empoli Vicario NaN 553 \n", "Szczesny 3 453 P Juventus Szczesny NaN 550 \n", "Falcone 4 2134 P Lecce Falcone NaN 530 \n", "... ... ... .. ... ... ... ... \n", "De Luca 538 5512 A Sampdoria Luca NaN 130 \n", "Voelkerling Persson 539 5837 A Lecce Persson NaN 494 \n", "Montevago 540 6113 A Sampdoria Montevago NaN 322 \n", "Krollis 541 6143 A Spezia Krollis NaN -1 \n", "Vivaldo 542 6160 A Udinese Vivaldo NaN -1 \n", "\n", " age birth_year games ... \\\n", "name ... \n", "Meret 25-319 1997 0 ... \n", "Provedel 28-324 1994 0 ... \n", "Vicario 26-120 1996 0 ... \n", "Szczesny 32-292 1990 0 ... \n", "Falcone 27-298 1995 0 ... \n", "... ... ... ... ... \n", "De Luca 24-202 1998 1 ... \n", "Voelkerling Persson 20-020 2003 2 ... \n", "Montevago 19-323 2003 6 ... \n", "Krollis 0 0 0 ... \n", "Vivaldo 0 0 0 ... \n", "\n", " gk_pct_goal_kicks_launched gk_goal_kick_length_avg \\\n", "name \n", "Meret 20.3 27.5 \n", "Provedel 33.6 34.2 \n", "Vicario 47.7 42.5 \n", "Szczesny 40.3 38.9 \n", "Falcone 75.0 51.4 \n", "... ... ... \n", "De Luca 0.0 0.0 \n", "Voelkerling Persson 0.0 0.0 \n", "Montevago 0.0 0.0 \n", "Krollis 0.0 0.0 \n", "Vivaldo 0.0 0.0 \n", "\n", " gk_crosses gk_crosses_stopped gk_crosses_stopped_pct \\\n", "name \n", "Meret 213.0 6.0 2.8 \n", "Provedel 266.0 7.0 2.6 \n", "Vicario 412.0 25.0 6.1 \n", "Szczesny 159.0 4.0 2.5 \n", "Falcone 302.0 13.0 4.3 \n", "... ... ... ... \n", "De Luca 0.0 0.0 0.0 \n", "Voelkerling Persson 0.0 0.0 0.0 \n", "Montevago 0.0 0.0 0.0 \n", "Krollis 0.0 0.0 0.0 \n", "Vivaldo 0.0 0.0 0.0 \n", "\n", " gk_def_actions_outside_pen_area \\\n", "name \n", "Meret 24.0 \n", "Provedel 37.0 \n", "Vicario 10.0 \n", "Szczesny 10.0 \n", "Falcone 20.0 \n", "... ... \n", "De Luca 0.0 \n", "Voelkerling Persson 0.0 \n", "Montevago 0.0 \n", "Krollis 0.0 \n", "Vivaldo 0.0 \n", "\n", " gk_def_actions_outside_pen_area_per90 \\\n", "name \n", "Meret 1.20 \n", "Provedel 1.86 \n", "Vicario 0.50 \n", "Szczesny 0.74 \n", "Falcone 1.00 \n", "... ... \n", "De Luca 0.00 \n", "Voelkerling Persson 0.00 \n", "Montevago 0.00 \n", "Krollis 0.00 \n", "Vivaldo 0.00 \n", "\n", " gk_avg_distance_def_actions vote_avg vote_std \n", "name \n", "Meret 17.2 6.275000 0.486698 \n", "Provedel 18.0 6.225000 0.334477 \n", "Vicario 10.7 6.450000 0.384057 \n", "Szczesny 15.1 6.035714 0.351745 \n", "Falcone 12.5 6.325000 0.363146 \n", "... ... ... ... \n", "De Luca 0.0 5.881660 0.665426 \n", "Voelkerling Persson 0.0 6.227492 0.259439 \n", "Montevago 0.0 5.956291 0.615163 \n", "Krollis 0.0 5.699562 0.705829 \n", "Vivaldo 0.0 5.888111 0.648879 \n", "\n", "[543 rows x 169 columns]" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rx = pd.read_excel('mid_outputs/players_stats.xlsx', index_col = 3) \n", "players = pd.DataFrame(rx)\n", "\n", "players\n" ] }, { "cell_type": "markdown", "id": "ae37dfe3", "metadata": {}, "source": [ "Function for merging match data (player, team, opponent team)" ] }, { "cell_type": "code", "execution_count": 54, "id": "71c8804e", "metadata": {}, "outputs": [], "source": [ "def player_match_data(player, pteam, oppteam):\n", " if(not(player in players.index)):\n", " return None\n", " \n", " pdata = players.loc[[player]]\n", " \n", " pteam_stats = team_data.loc[[pteam]].rename(index = {pteam : player})\n", " \n", " oppteam_stats = team_data.loc[[oppteam]].rename(index = {oppteam : player})\n", " \n", " oppteam_stats = oppteam_stats.rename(lambda x: 'opp_' + x, axis='columns')\n", " \n", " out = pd.concat([pdata, pteam_stats, oppteam_stats], axis = 1)\n", " \n", " return(out)\n", " " ] }, { "cell_type": "markdown", "id": "a6fdd15b", "metadata": {}, "source": [ "Output to excel file data for a player. \n", "\n", "The file is copied and there the desired features are manually selected and printed." ] }, { "cell_type": "code", "execution_count": 55, "id": "7eb4e666", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0idrteamsurnameinitialfb_IDagebirth_yeargames...opp_vs_team_foulsopp_vs_team_fouledopp_vs_team_offsidesopp_vs_team_pens_wonopp_vs_team_pens_concededopp_vs_team_own_goalsopp_vs_team_ball_recoveriesopp_vs_team_aerials_wonopp_vs_team_aerials_lostopp_vs_team_aerials_won_pct
Frattesi2742848CSassuoloFrattesiNaN18723-105199920...220.0232.026.01.08.01.01214.0248.0303.045.0
\n", "

1 rows × 811 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "Frattesi 274 2848 C Sassuolo Frattesi NaN 187 23-105 \n", "\n", " birth_year games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Frattesi 1999 20 ... 220.0 232.0 \n", "\n", " opp_vs_team_offsides opp_vs_team_pens_won \\\n", "Frattesi 26.0 1.0 \n", "\n", " opp_vs_team_pens_conceded opp_vs_team_own_goals \\\n", "Frattesi 8.0 1.0 \n", "\n", " opp_vs_team_ball_recoveries opp_vs_team_aerials_won \\\n", "Frattesi 1214.0 248.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Frattesi 303.0 45.0 \n", "\n", "[1 rows x 811 columns]" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data('Frattesi', 'Sassuolo', 'Atalanta')\n", "test.to_excel('tmp/playermatchdata.xlsx')\n", "\n", "test" ] }, { "cell_type": "code", "execution_count": 56, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Sassuolo'" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pteam = 'Sassuolo'\n", "pteam_stats = team_data.loc[[pteam]]\n", "pteam_stats.index[0]" ] }, { "cell_type": "code", "execution_count": 57, "id": "6ea6df1f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['r',\n", " 'fb_ID',\n", " 'games',\n", " 'games_starts',\n", " 'minutes',\n", " 'goals',\n", " 'assists',\n", " 'cards_yellow',\n", " 'cards_red',\n", " 'xg',\n", " 'npxg',\n", " 'shots_on_target',\n", " 'shots_on_target_pct',\n", " 'goals_per_shot',\n", " 'goals_per_shot_on_target',\n", " 'passes_completed',\n", " 'passes_pct',\n", " 'passes_into_final_third',\n", " 'passes_into_penalty_area',\n", " 'progressive_passes',\n", " 'passes_live',\n", " 'passes_dead',\n", " 'through_balls',\n", " 'passes_switches',\n", " 'crosses',\n", " 'corner_kicks',\n", " 'dribble_tackles',\n", " 'dribbles_vs',\n", " 'dribble_tackles_pct',\n", " 'dribbled_past',\n", " 'blocks',\n", " 'blocked_shots',\n", " 'blocked_passes',\n", " 'interceptions',\n", " 'clearances',\n", " 'errors',\n", " 'touches',\n", " 'touches_def_pen_area',\n", " 'touches_def_3rd',\n", " 'touches_mid_3rd',\n", " 'touches_att_3rd',\n", " 'touches_att_pen_area',\n", " 'touches_live_ball',\n", " 'dribbles_completed',\n", " 'dribbles',\n", " 'dribbles_completed_pct',\n", " 'carries',\n", " 'progressive_carries',\n", " 'carries_into_final_third',\n", " 'carries_into_penalty_area',\n", " 'passes_received',\n", " 'miscontrols',\n", " 'dispossessed',\n", " 'fouls',\n", " 'fouled',\n", " 'aerials_won',\n", " 'aerials_lost',\n", " 'aerials_won_pct',\n", " 'team_possession',\n", " 'team_goals_assists_per90',\n", " 'team_goals_pens_per90',\n", " 'team_goals_assists_pens_per90',\n", " 'team_xg_per90',\n", " 'team_gk_goals_against_per90',\n", " 'team_gk_save_pct',\n", " 'team_gk_clean_sheets_pct',\n", " 'team_passes_pct',\n", " 'team_passes_pct_medium',\n", " 'team_passes_pct_long',\n", " 'team_sca_per90',\n", " 'team_gca_per90',\n", " 'team_dribble_tackles_pct',\n", " 'team_aerials_won_pct',\n", " 'vs_team_possession',\n", " 'vs_team_goals_per90',\n", " 'vs_team_assists_per90',\n", " 'vs_team_xg_per90',\n", " 'vs_team_gk_save_pct',\n", " 'vs_team_gk_clean_sheets_pct',\n", " 'vs_team_gk_pct_passes_launched',\n", " 'vs_team_gk_crosses_stopped_pct',\n", " 'vs_team_shots_on_target_per90',\n", " 'vs_team_passes_pct',\n", " 'vs_team_passes_pct_short',\n", " 'vs_team_passes_pct_medium',\n", " 'vs_team_passes_pct_long',\n", " 'vs_team_sca_per90',\n", " 'vs_team_gca_per90',\n", " 'vs_team_dribble_tackles_pct',\n", " 'vs_team_dribbles_completed_pct',\n", " 'vs_team_aerials_won_pct']" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rx = pd.read_excel('tmp/playermatchdata_sel.xlsx', index_col = 0, header = None) \n", "\n", "out = list()\n", "\n", "for i in range(1, rx.shape[1]):\n", " if(rx[i][2] == \"x\"):\n", " out.append(rx[i][0])\n", " \n", "out" ] }, { "cell_type": "markdown", "id": "d4097382", "metadata": {}, "source": [ "Define and select the dataset features: abs features and rel features.\n", " \n", "Rel features are divided by the player minutes played.\n", "\n", "Rel features (game corrected) are divided by the player number of games instead of minutes. \n", "For example, a player who plays 20 minutes and scores, would be to match for stats averaging. It is better to consider the goals made per match." ] }, { "cell_type": "code", "execution_count": 58, "id": "47bc651f", "metadata": {}, "outputs": [], "source": [ "features_abs = ['r',\n", " 'games',\n", " 'games_starts', \n", " 'minutes',\n", " 'shots_on_target_pct',\n", " 'goals_per_shot',\n", " 'goals_per_shot_on_target',\n", " 'passes_pct',\n", " 'dribble_tackles_pct',\n", " 'dribbles_completed_pct',\n", " 'aerials_won_pct',\n", " 'team_possession',\n", " 'team_goals_assists_per90',\n", " 'team_goals_pens_per90',\n", " 'team_goals_assists_pens_per90',\n", " 'team_xg_per90',\n", " 'team_gk_goals_against_per90',\n", " 'team_gk_save_pct',\n", " 'team_gk_clean_sheets_pct',\n", " 'team_passes_pct',\n", " 'team_passes_pct_medium',\n", " 'team_passes_pct_long',\n", " 'team_sca_per90',\n", " 'team_gca_per90',\n", " 'team_dribble_tackles_pct',\n", " 'team_aerials_won_pct',\n", " 'vs_team_possession',\n", " 'vs_team_goals_per90',\n", " 'vs_team_assists_per90',\n", " 'vs_team_xg_per90',\n", " 'vs_team_gk_save_pct',\n", " 'vs_team_gk_clean_sheets_pct',\n", " 'vs_team_gk_pct_passes_launched',\n", " 'vs_team_gk_crosses_stopped_pct',\n", " 'vs_team_shots_on_target_per90',\n", " 'vs_team_passes_pct',\n", " 'vs_team_passes_pct_short',\n", " 'vs_team_passes_pct_medium',\n", " 'vs_team_passes_pct_long',\n", " 'vs_team_sca_per90',\n", " 'vs_team_gca_per90',\n", " 'vs_team_dribble_tackles_pct',\n", " 'vs_team_dribbles_completed_pct',\n", " 'vs_team_aerials_won_pct',\n", " 'opp_team_possession',\n", " 'opp_team_goals_assists_per90',\n", " 'opp_team_goals_pens_per90',\n", " 'opp_team_goals_assists_pens_per90',\n", " 'opp_team_xg_per90',\n", " 'opp_team_gk_goals_against_per90',\n", " 'opp_team_gk_save_pct',\n", " 'opp_team_gk_clean_sheets_pct',\n", " 'opp_team_passes_pct',\n", " 'opp_team_passes_pct_medium',\n", " 'opp_team_passes_pct_long',\n", " 'opp_team_sca_per90',\n", " 'opp_team_gca_per90',\n", " 'opp_team_dribble_tackles_pct',\n", " 'opp_team_aerials_won_pct',\n", " 'opp_vs_team_possession',\n", " 'opp_vs_team_goals_per90',\n", " 'opp_vs_team_assists_per90',\n", " 'opp_vs_team_xg_per90',\n", " 'opp_vs_team_gk_save_pct',\n", " 'opp_vs_team_gk_clean_sheets_pct',\n", " 'opp_vs_team_gk_pct_passes_launched',\n", " 'opp_vs_team_gk_crosses_stopped_pct',\n", " 'opp_vs_team_shots_on_target_per90',\n", " 'opp_vs_team_passes_pct',\n", " 'opp_vs_team_passes_pct_short',\n", " 'opp_vs_team_passes_pct_medium',\n", " 'opp_vs_team_passes_pct_long',\n", " 'opp_vs_team_sca_per90',\n", " 'opp_vs_team_gca_per90',\n", " 'opp_vs_team_dribble_tackles_pct',\n", " 'opp_vs_team_dribbles_completed_pct',\n", " 'opp_vs_team_aerials_won_pct',\n", " \n", " 'vote_avg',\n", " 'vote_std']\n", "\n", "features_rel = [\n", " 'goals',\n", " 'assists',\n", " 'cards_yellow',\n", " 'cards_red',\n", " 'xg',\n", " 'npxg',\n", " 'shots_on_target',\n", " 'passes_completed',\n", " 'passes_into_final_third',\n", " 'passes_into_penalty_area',\n", " 'progressive_passes',\n", " 'passes_live',\n", " 'passes_dead',\n", " 'through_balls',\n", " 'passes_switches',\n", " 'crosses',\n", " 'corner_kicks',\n", " 'dribble_tackles',\n", " 'dribbles_vs',\n", " 'dribbled_past',\n", " 'blocks',\n", " 'blocked_shots',\n", " 'blocked_passes',\n", " 'interceptions',\n", " 'clearances',\n", " 'errors',\n", " 'touches',\n", " 'touches_def_pen_area',\n", " 'touches_def_3rd',\n", " 'touches_mid_3rd',\n", " 'touches_att_3rd',\n", " 'touches_att_pen_area',\n", " 'touches_live_ball',\n", " 'dribbles_completed',\n", " 'dribbles',\n", " 'passes_received',\n", " 'miscontrols',\n", " 'dispossessed',\n", " 'fouls',\n", " 'fouled',\n", " 'aerials_won',\n", " 'aerials_lost',\n", " 'carries',\n", " 'progressive_carries',\n", " 'carries_into_final_third',\n", " 'carries_into_penalty_area']\n", "\n", "features_rel_gamecorr = [\n", " 'goals',\n", " 'assists',\n", " 'xg',\n", " 'npxg',\n", " 'cards_yellow',\n", " 'cards_red'\n", "]" ] }, { "cell_type": "markdown", "id": "ced70285", "metadata": {}, "source": [ "Function for merging match data (player, team, opponent team) and select only the desired features, applying the desired corrections." ] }, { "cell_type": "code", "execution_count": 59, "id": "3f43d509", "metadata": {}, "outputs": [], "source": [ "def player_match_data_ext(player, pteam, oppteam):\n", " pdata = player_match_data(player, pteam, oppteam)\n", " \n", " if(not isinstance(pdata, pd.DataFrame)):\n", " return None\n", " \n", " out = pd.concat([pdata[features_abs], pdata[features_rel]], axis = 1)\n", " \n", " out[features_rel] = out[features_rel] / max(pdata['minutes'][0], 1)\n", " \n", " out[features_rel_gamecorr] = out[features_rel_gamecorr] * (pdata['minutes'][0] / max(pdata['games'][0], 1) / 90)\n", " \n", " return out\n", " " ] }, { "cell_type": "markdown", "id": "959bf152", "metadata": {}, "source": [ "Columns variable for the match data, to be then added to votes data." ] }, { "cell_type": "code", "execution_count": 60, "id": "930d00c7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
rgamesgames_startsminutesshots_on_target_pctgoals_per_shotgoals_per_shot_on_targetpasses_pctdribble_tackles_pctdribbles_completed_pct...miscontrolsdispossessedfoulsfouledaerials_wonaerials_lostcarriesprogressive_carriescarries_into_final_thirdcarries_into_penalty_area
FrattesiC2020163650.00.140.2877.758.352.2...0.0177260.0171150.0158920.0220050.009780.0073350.2713940.0262840.0183370.008557
\n", "

1 rows × 125 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct \\\n", "Frattesi C 20 20 1636 50.0 \n", "\n", " goals_per_shot goals_per_shot_on_target passes_pct \\\n", "Frattesi 0.14 0.28 77.7 \n", "\n", " dribble_tackles_pct dribbles_completed_pct ... miscontrols \\\n", "Frattesi 58.3 52.2 ... 0.017726 \n", "\n", " dispossessed fouls fouled aerials_won aerials_lost \\\n", "Frattesi 0.017115 0.015892 0.022005 0.00978 0.007335 \n", "\n", " carries progressive_carries carries_into_final_third \\\n", "Frattesi 0.271394 0.026284 0.018337 \n", "\n", " carries_into_penalty_area \n", "Frattesi 0.008557 \n", "\n", "[1 rows x 125 columns]" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data_ext('Frattesi', 'Sassuolo', 'Atalanta')\n", "\n", "add_columns = test.columns\n", "\n", "test" ] }, { "cell_type": "markdown", "id": "8d95c9ef", "metadata": {}, "source": [ "Load Fantacalcio votes data for each match of the season." ] }, { "cell_type": "code", "execution_count": 61, "id": "3ae718d2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
matchdayplayerteamoppteamhomevotegoalsassistscards_malusfantavote
01MussoAtalantaSampdoria06.0000.55.5
11ToloiAtalantaSampdoria07.0100.010.0
21DjimsitiAtalantaSampdoria06.0000.06.0
31HateboerAtalantaSampdoria06.0000.55.5
41OkoliAtalantaSampdoria05.5000.55.0
.................................
571020Sulemana I.VeronaUdinese05.5000.55.0
571120LasagnaVeronaUdinese05.5000.05.5
571220BraafVeronaUdinese05.0000.05.0
571320DjuricVeronaUdinese06.0000.06.0
571420NgongeVeronaUdinese06.0000.06.0
\n", "

5715 rows × 10 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Sampdoria 0 6.0 0 0 \n", "1 1 Toloi Atalanta Sampdoria 0 7.0 1 0 \n", "2 1 Djimsiti Atalanta Sampdoria 0 6.0 0 0 \n", "3 1 Hateboer Atalanta Sampdoria 0 6.0 0 0 \n", "4 1 Okoli Atalanta Sampdoria 0 5.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "5710 20 Sulemana I. Verona Udinese 0 5.5 0 0 \n", "5711 20 Lasagna Verona Udinese 0 5.5 0 0 \n", "5712 20 Braaf Verona Udinese 0 5.0 0 0 \n", "5713 20 Djuric Verona Udinese 0 6.0 0 0 \n", "5714 20 Ngonge Verona Udinese 0 6.0 0 0 \n", "\n", " cards_malus fantavote \n", "0 0.5 5.5 \n", "1 0.0 10.0 \n", "2 0.0 6.0 \n", "3 0.5 5.5 \n", "4 0.5 5.0 \n", "... ... ... \n", "5710 0.5 5.0 \n", "5711 0.0 5.5 \n", "5712 0.0 5.0 \n", "5713 0.0 6.0 \n", "5714 0.0 6.0 \n", "\n", "[5715 rows x 10 columns]" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "votes = pd.read_excel('mid_outputs/players_votes.xlsx', index_col = 0)\n", "votes" ] }, { "cell_type": "markdown", "id": "8cf677e4", "metadata": {}, "source": [ "Merge votes data with match data for the player." ] }, { "cell_type": "code", "execution_count": 62, "id": "ec0bc56b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "100\n", "200\n", "300\n", "400\n", "500\n", "700\n", "800\n", "900\n", "1000\n", "1100\n", "1300\n", "1400\n", "1500\n", "1600\n", "1700\n", "1800\n", "1900\n", "2000\n", "2200\n", "2300\n", "2400\n", "2500\n", "2600\n", "2700\n", "2800\n", "2900\n", "3000\n", "3100\n", "3200\n", "3300\n", "3400\n", "3500\n", "3600\n", "3700\n", "3800\n", "3900\n", "4000\n", "4100\n", "4200\n", "4300\n", "4400\n", "4500\n", "4600\n", "4700\n", "4800\n", "4900\n", "5000\n", "5100\n", "5200\n", "5300\n", "5400\n", "5500\n", "5600\n", "5700\n" ] } ], "source": [ "db = votes.copy()\n", "\n", "delta = pd.DataFrame(columns = add_columns)\n", "\n", "for i in range(db.shape[0]):\n", " ext_data = player_match_data_ext(db['player'][i], db['team'][i], db['oppteam'][i])\n", " \n", " if(not isinstance(ext_data, pd.DataFrame)):\n", " continue\n", " \n", " ext_data = ext_data.rename(index = {db['player'][i] : i})\n", " \n", " delta = pd.concat([delta, ext_data], axis = 0)\n", " \n", " if(i % 100 == 0):\n", " print(i)\n", " \n", "db = pd.concat([db, delta], axis = 1)\n", " " ] }, { "cell_type": "code", "execution_count": 63, "id": "b292f9f9", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
matchdayplayerteamoppteamhomevotegoalsassistscards_malusfantavote...miscontrolsdispossessedfoulsfouledaerials_wonaerials_lostcarriesprogressive_carriescarries_into_final_thirdcarries_into_penalty_area
01MussoAtalantaSampdoria06.0000.55.5...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
11ToloiAtalantaSampdoria07.0100.010.0...0.0078860.0015770.0063090.0063090.0149840.0118300.3643530.0086750.0165620.000000
21DjimsitiAtalantaSampdoria06.0000.06.0...0.0022570.0067720.0067720.0045150.0203160.0158010.4830700.0045150.0045150.000000
31HateboerAtalantaSampdoria06.0000.55.5...0.0063040.0047280.0126080.0015760.0165480.0110320.2844760.0126080.0086680.000788
41OkoliAtalantaSampdoria05.5000.55.0...0.0130180.0035500.0153850.0082840.0473370.0272190.2698220.0023670.0047340.000000
..................................................................
571020Sulemana I.VeronaUdinese05.5000.55.0...0.0170450.0142050.0198860.0056820.0170450.0227270.2215910.0085230.0113640.000000
571120LasagnaVeronaUdinese05.5000.05.5...0.0350880.0253410.0194930.0155950.0068230.0302140.1705650.0243660.0136450.009747
571220BraafVeronaUdinese05.0000.05.0...0.0416670.0694440.0277780.0000000.0000000.0277780.2083330.0138890.0000000.000000
571320DjuricVeronaUdinese06.0000.06.0...0.0270270.0056900.0213370.0199150.1607400.0398290.2048360.0014220.0028450.002845
571420NgongeVeronaUdinese06.0000.06.0...0.0000000.0555560.0000000.0000000.0000000.1111110.3888890.1111110.0000000.111111
\n", "

5715 rows × 135 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Sampdoria 0 6.0 0 0 \n", "1 1 Toloi Atalanta Sampdoria 0 7.0 1 0 \n", "2 1 Djimsiti Atalanta Sampdoria 0 6.0 0 0 \n", "3 1 Hateboer Atalanta Sampdoria 0 6.0 0 0 \n", "4 1 Okoli Atalanta Sampdoria 0 5.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "5710 20 Sulemana I. Verona Udinese 0 5.5 0 0 \n", "5711 20 Lasagna Verona Udinese 0 5.5 0 0 \n", "5712 20 Braaf Verona Udinese 0 5.0 0 0 \n", "5713 20 Djuric Verona Udinese 0 6.0 0 0 \n", "5714 20 Ngonge Verona Udinese 0 6.0 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "0 0.5 5.5 ... 0.000000 0.000000 0.000000 \n", "1 0.0 10.0 ... 0.007886 0.001577 0.006309 \n", "2 0.0 6.0 ... 0.002257 0.006772 0.006772 \n", "3 0.5 5.5 ... 0.006304 0.004728 0.012608 \n", "4 0.5 5.0 ... 0.013018 0.003550 0.015385 \n", "... ... ... ... ... ... ... \n", "5710 0.5 5.0 ... 0.017045 0.014205 0.019886 \n", "5711 0.0 5.5 ... 0.035088 0.025341 0.019493 \n", "5712 0.0 5.0 ... 0.041667 0.069444 0.027778 \n", "5713 0.0 6.0 ... 0.027027 0.005690 0.021337 \n", "5714 0.0 6.0 ... 0.000000 0.055556 0.000000 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "0 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "1 0.006309 0.014984 0.011830 0.364353 0.008675 \n", "2 0.004515 0.020316 0.015801 0.483070 0.004515 \n", "3 0.001576 0.016548 0.011032 0.284476 0.012608 \n", "4 0.008284 0.047337 0.027219 0.269822 0.002367 \n", "... ... ... ... ... ... \n", "5710 0.005682 0.017045 0.022727 0.221591 0.008523 \n", "5711 0.015595 0.006823 0.030214 0.170565 0.024366 \n", "5712 0.000000 0.000000 0.027778 0.208333 0.013889 \n", "5713 0.019915 0.160740 0.039829 0.204836 0.001422 \n", "5714 0.000000 0.000000 0.111111 0.388889 0.111111 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "0 0.000000 0.000000 \n", "1 0.016562 0.000000 \n", "2 0.004515 0.000000 \n", "3 0.008668 0.000788 \n", "4 0.004734 0.000000 \n", "... ... ... \n", "5710 0.011364 0.000000 \n", "5711 0.013645 0.009747 \n", "5712 0.000000 0.000000 \n", "5713 0.002845 0.002845 \n", "5714 0.000000 0.111111 \n", "\n", "[5715 rows x 135 columns]" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "markdown", "id": "d237f87b", "metadata": {}, "source": [ "Remove undesired database entries." ] }, { "cell_type": "code", "execution_count": 64, "id": "1db9f77f", "metadata": {}, "outputs": [], "source": [ "db = db.drop(db[db.r == 'P'].index) # remove goalkeepers\n", "db = db.drop(db[db.r != db.r].index) # remove non existing players (by searching NaN values)\n", "db = db.drop(db[db.xg != db.xg].index)\n" ] }, { "cell_type": "code", "execution_count": 65, "id": "f56df3ca", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
matchdayplayerteamoppteamhomevotegoalsassistscards_malusfantavote...miscontrolsdispossessedfoulsfouledaerials_wonaerials_lostcarriesprogressive_carriescarries_into_final_thirdcarries_into_penalty_area
11ToloiAtalantaSampdoria07.0100.010.0...0.0078860.0015770.0063090.0063090.0149840.0118300.3643530.0086750.0165620.000000
21DjimsitiAtalantaSampdoria06.0000.06.0...0.0022570.0067720.0067720.0045150.0203160.0158010.4830700.0045150.0045150.000000
31HateboerAtalantaSampdoria06.0000.55.5...0.0063040.0047280.0126080.0015760.0165480.0110320.2844760.0126080.0086680.000788
41OkoliAtalantaSampdoria05.5000.55.0...0.0130180.0035500.0153850.0082840.0473370.0272190.2698220.0023670.0047340.000000
51ZorteaAtalantaSampdoria06.0000.55.5...0.0270270.0090090.0180180.0000000.0225230.0045050.3513510.0495500.0315320.009009
..................................................................
571020Sulemana I.VeronaUdinese05.5000.55.0...0.0170450.0142050.0198860.0056820.0170450.0227270.2215910.0085230.0113640.000000
571120LasagnaVeronaUdinese05.5000.05.5...0.0350880.0253410.0194930.0155950.0068230.0302140.1705650.0243660.0136450.009747
571220BraafVeronaUdinese05.0000.05.0...0.0416670.0694440.0277780.0000000.0000000.0277780.2083330.0138890.0000000.000000
571320DjuricVeronaUdinese06.0000.06.0...0.0270270.0056900.0213370.0199150.1607400.0398290.2048360.0014220.0028450.002845
571420NgongeVeronaUdinese06.0000.06.0...0.0000000.0555560.0000000.0000000.0000000.1111110.3888890.1111110.0000000.111111
\n", "

5069 rows × 135 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "1 1 Toloi Atalanta Sampdoria 0 7.0 1 0 \n", "2 1 Djimsiti Atalanta Sampdoria 0 6.0 0 0 \n", "3 1 Hateboer Atalanta Sampdoria 0 6.0 0 0 \n", "4 1 Okoli Atalanta Sampdoria 0 5.5 0 0 \n", "5 1 Zortea Atalanta Sampdoria 0 6.0 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "5710 20 Sulemana I. Verona Udinese 0 5.5 0 0 \n", "5711 20 Lasagna Verona Udinese 0 5.5 0 0 \n", "5712 20 Braaf Verona Udinese 0 5.0 0 0 \n", "5713 20 Djuric Verona Udinese 0 6.0 0 0 \n", "5714 20 Ngonge Verona Udinese 0 6.0 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "1 0.0 10.0 ... 0.007886 0.001577 0.006309 \n", "2 0.0 6.0 ... 0.002257 0.006772 0.006772 \n", "3 0.5 5.5 ... 0.006304 0.004728 0.012608 \n", "4 0.5 5.0 ... 0.013018 0.003550 0.015385 \n", "5 0.5 5.5 ... 0.027027 0.009009 0.018018 \n", "... ... ... ... ... ... ... \n", "5710 0.5 5.0 ... 0.017045 0.014205 0.019886 \n", "5711 0.0 5.5 ... 0.035088 0.025341 0.019493 \n", "5712 0.0 5.0 ... 0.041667 0.069444 0.027778 \n", "5713 0.0 6.0 ... 0.027027 0.005690 0.021337 \n", "5714 0.0 6.0 ... 0.000000 0.055556 0.000000 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "1 0.006309 0.014984 0.011830 0.364353 0.008675 \n", "2 0.004515 0.020316 0.015801 0.483070 0.004515 \n", "3 0.001576 0.016548 0.011032 0.284476 0.012608 \n", "4 0.008284 0.047337 0.027219 0.269822 0.002367 \n", "5 0.000000 0.022523 0.004505 0.351351 0.049550 \n", "... ... ... ... ... ... \n", "5710 0.005682 0.017045 0.022727 0.221591 0.008523 \n", "5711 0.015595 0.006823 0.030214 0.170565 0.024366 \n", "5712 0.000000 0.000000 0.027778 0.208333 0.013889 \n", "5713 0.019915 0.160740 0.039829 0.204836 0.001422 \n", "5714 0.000000 0.000000 0.111111 0.388889 0.111111 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "1 0.016562 0.000000 \n", "2 0.004515 0.000000 \n", "3 0.008668 0.000788 \n", "4 0.004734 0.000000 \n", "5 0.031532 0.009009 \n", "... ... ... \n", "5710 0.011364 0.000000 \n", "5711 0.013645 0.009747 \n", "5712 0.000000 0.000000 \n", "5713 0.002845 0.002845 \n", "5714 0.000000 0.111111 \n", "\n", "[5069 rows x 135 columns]" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "markdown", "id": "ab69d09e", "metadata": {}, "source": [ "Save outfield players database to file." ] }, { "cell_type": "code", "execution_count": 66, "id": "df26c8e0", "metadata": {}, "outputs": [], "source": [ "db.to_excel('mid_outputs/database_entries.xlsx')" ] }, { "cell_type": "markdown", "id": "38b564d2", "metadata": {}, "source": [ "Do the same process for goalkeepers, generating a different database." ] }, { "cell_type": "code", "execution_count": 22, "id": "4d06576a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 - matchday\n", "1 - player\n", "2 - team\n", "3 - oppteam\n", "4 - home\n", "5 - vote\n", "6 - goals\n", "7 - assists\n", "8 - cards_malus\n", "9 - fantavote\n", "10 - r\n", "11 - games\n", "12 - games_starts\n", "13 - minutes\n", "14 - shots_on_target_pct\n", "15 - goals_per_shot\n", "16 - goals_per_shot_on_target\n", "17 - passes_pct\n", "18 - dribble_tackles_pct\n", "19 - dribbles_completed_pct\n", "20 - aerials_won_pct\n", "21 - team_possession\n", "22 - team_goals_assists_per90\n", "23 - team_goals_pens_per90\n", "24 - team_goals_assists_pens_per90\n", "25 - team_xg_per90\n", "26 - team_gk_goals_against_per90\n", "27 - team_gk_save_pct\n", "28 - team_gk_clean_sheets_pct\n", "29 - team_passes_pct\n", "30 - team_passes_pct_medium\n", "31 - team_passes_pct_long\n", "32 - team_sca_per90\n", "33 - team_gca_per90\n", "34 - team_dribble_tackles_pct\n", "35 - team_aerials_won_pct\n", "36 - vs_team_possession\n", "37 - vs_team_goals_per90\n", "38 - vs_team_assists_per90\n", "39 - vs_team_xg_per90\n", "40 - vs_team_gk_save_pct\n", "41 - vs_team_gk_clean_sheets_pct\n", "42 - vs_team_gk_pct_passes_launched\n", "43 - vs_team_gk_crosses_stopped_pct\n", "44 - vs_team_shots_on_target_per90\n", "45 - vs_team_passes_pct\n", "46 - vs_team_passes_pct_short\n", "47 - vs_team_passes_pct_medium\n", "48 - vs_team_passes_pct_long\n", "49 - vs_team_sca_per90\n", "50 - vs_team_gca_per90\n", "51 - vs_team_dribble_tackles_pct\n", "52 - vs_team_dribbles_completed_pct\n", "53 - vs_team_aerials_won_pct\n", "54 - opp_team_possession\n", "55 - opp_team_goals_assists_per90\n", "56 - opp_team_goals_pens_per90\n", "57 - opp_team_goals_assists_pens_per90\n", "58 - opp_team_xg_per90\n", "59 - opp_team_gk_goals_against_per90\n", "60 - opp_team_gk_save_pct\n", "61 - opp_team_gk_clean_sheets_pct\n", "62 - opp_team_passes_pct\n", "63 - opp_team_passes_pct_medium\n", "64 - opp_team_passes_pct_long\n", "65 - opp_team_sca_per90\n", "66 - opp_team_gca_per90\n", "67 - opp_team_dribble_tackles_pct\n", "68 - opp_team_aerials_won_pct\n", "69 - opp_vs_team_possession\n", "70 - opp_vs_team_goals_per90\n", "71 - opp_vs_team_assists_per90\n", "72 - opp_vs_team_xg_per90\n", "73 - opp_vs_team_gk_save_pct\n", "74 - opp_vs_team_gk_clean_sheets_pct\n", "75 - opp_vs_team_gk_pct_passes_launched\n", "76 - opp_vs_team_gk_crosses_stopped_pct\n", "77 - opp_vs_team_shots_on_target_per90\n", "78 - opp_vs_team_passes_pct\n", "79 - opp_vs_team_passes_pct_short\n", "80 - opp_vs_team_passes_pct_medium\n", "81 - opp_vs_team_passes_pct_long\n", "82 - opp_vs_team_sca_per90\n", "83 - opp_vs_team_gca_per90\n", "84 - opp_vs_team_dribble_tackles_pct\n", "85 - opp_vs_team_dribbles_completed_pct\n", "86 - opp_vs_team_aerials_won_pct\n", "87 - vote_avg\n", "88 - vote_std\n", "89 - goals\n", "90 - assists\n", "91 - cards_yellow\n", "92 - cards_red\n", "93 - xg\n", "94 - npxg\n", "95 - shots_on_target\n", "96 - passes_completed\n", "97 - passes_into_final_third\n", "98 - passes_into_penalty_area\n", "99 - progressive_passes\n", "100 - passes_live\n", "101 - passes_dead\n", "102 - through_balls\n", "103 - passes_switches\n", "104 - crosses\n", "105 - corner_kicks\n", "106 - dribble_tackles\n", "107 - dribbles_vs\n", "108 - dribbled_past\n", "109 - blocks\n", "110 - blocked_shots\n", "111 - blocked_passes\n", "112 - interceptions\n", "113 - clearances\n", "114 - errors\n", "115 - touches\n", "116 - touches_def_pen_area\n", "117 - touches_def_3rd\n", "118 - touches_mid_3rd\n", "119 - touches_att_3rd\n", "120 - touches_att_pen_area\n", "121 - touches_live_ball\n", "122 - dribbles_completed\n", "123 - dribbles\n", "124 - passes_received\n", "125 - miscontrols\n", "126 - dispossessed\n", "127 - fouls\n", "128 - fouled\n", "129 - aerials_won\n", "130 - aerials_lost\n" ] } ], "source": [ "for i in range(db.columns.shape[0]):\n", " print(str(i) + \" - \" + str(db.columns[i]))" ] }, { "cell_type": "code", "execution_count": 23, "id": "01bb7413", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['r',\n", " 'fb_ID',\n", " 'gk_games',\n", " 'gk_games_starts',\n", " 'gk_minutes',\n", " 'gk_goals_against_per90',\n", " 'gk_shots_on_target_against',\n", " 'gk_saves',\n", " 'gk_save_pct',\n", " 'gk_clean_sheets_pct',\n", " 'gk_free_kick_goals_against',\n", " 'gk_corner_kick_goals_against',\n", " 'gk_own_goals_against',\n", " 'gk_psxg',\n", " 'gk_psnpxg_per_shot_on_target_against',\n", " 'gk_psxg_net',\n", " 'gk_psxg_net_per90',\n", " 'gk_passes_completed_launched',\n", " 'gk_passes_launched',\n", " 'gk_passes_pct_launched',\n", " 'gk_passes',\n", " 'gk_passes_throws',\n", " 'gk_pct_passes_launched',\n", " 'gk_passes_length_avg',\n", " 'gk_goal_kicks',\n", " 'gk_pct_goal_kicks_launched',\n", " 'gk_goal_kick_length_avg',\n", " 'gk_crosses',\n", " 'gk_crosses_stopped',\n", " 'gk_crosses_stopped_pct',\n", " 'gk_def_actions_outside_pen_area',\n", " 'gk_def_actions_outside_pen_area_per90',\n", " 'gk_avg_distance_def_actions',\n", " 'team_possession',\n", " 'team_goals_assists_per90',\n", " 'team_goals_pens_per90',\n", " 'team_goals_assists_pens_per90',\n", " 'team_xg_per90',\n", " 'team_gk_goals_against_per90',\n", " 'team_gk_save_pct',\n", " 'team_gk_clean_sheets_pct',\n", " 'team_passes_pct',\n", " 'team_passes_pct_medium',\n", " 'team_passes_pct_long',\n", " 'team_sca_per90',\n", " 'team_gca_per90',\n", " 'team_dribble_tackles_pct',\n", " 'team_aerials_won_pct',\n", " 'vs_team_possession',\n", " 'vs_team_goals_per90',\n", " 'vs_team_assists_per90',\n", " 'vs_team_xg_per90',\n", " 'vs_team_gk_save_pct',\n", " 'vs_team_gk_clean_sheets_pct',\n", " 'vs_team_gk_pct_passes_launched',\n", " 'vs_team_gk_crosses_stopped_pct',\n", " 'vs_team_shots_on_target_per90',\n", " 'vs_team_passes_pct',\n", " 'vs_team_passes_pct_short',\n", " 'vs_team_passes_pct_medium',\n", " 'vs_team_passes_pct_long',\n", " 'vs_team_sca_per90',\n", " 'vs_team_gca_per90',\n", " 'vs_team_dribble_tackles_pct',\n", " 'vs_team_dribbles_completed_pct',\n", " 'vs_team_aerials_won_pct']" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rx = pd.read_excel('tmp/playermatchdata_sel_gk.xlsx', index_col = 0, header = None) \n", "\n", "out = list()\n", "\n", "for i in range(1, rx.shape[1]):\n", " if(rx[i][2] == \"x\"):\n", " out.append(rx[i][0])\n", " \n", "out" ] }, { "cell_type": "code", "execution_count": 24, "id": "02f961d8", "metadata": {}, "outputs": [], "source": [ "features_abs_gk = [\n", " 'gk_games',\n", " 'gk_games_starts',\n", " 'gk_minutes',\n", " 'gk_goals_against_per90', \n", " 'gk_save_pct',\n", " 'gk_clean_sheets_pct',\n", " 'gk_psxg_net_per90',\n", " 'gk_passes_pct_launched',\n", " 'gk_pct_passes_launched',\n", " 'gk_passes_length_avg',\n", " 'gk_pct_goal_kicks_launched',\n", " 'gk_goal_kick_length_avg',\n", " 'gk_crosses_stopped_pct',\n", " 'gk_def_actions_outside_pen_area_per90',\n", " 'gk_avg_distance_def_actions',\n", " \n", " 'team_possession',\n", " 'team_goals_assists_per90',\n", " 'team_goals_pens_per90',\n", " 'team_goals_assists_pens_per90',\n", " 'team_xg_per90',\n", " 'team_gk_goals_against_per90',\n", " 'team_gk_save_pct',\n", " 'team_gk_clean_sheets_pct',\n", " 'team_passes_pct',\n", " 'team_passes_pct_medium',\n", " 'team_passes_pct_long',\n", " 'team_sca_per90',\n", " 'team_gca_per90',\n", " 'team_dribble_tackles_pct',\n", " 'team_aerials_won_pct',\n", " 'vs_team_possession',\n", " 'vs_team_goals_per90',\n", " 'vs_team_assists_per90',\n", " 'vs_team_xg_per90',\n", " 'vs_team_gk_save_pct',\n", " 'vs_team_gk_clean_sheets_pct',\n", " 'vs_team_gk_pct_passes_launched',\n", " 'vs_team_gk_crosses_stopped_pct',\n", " 'vs_team_shots_on_target_per90',\n", " 'vs_team_passes_pct',\n", " 'vs_team_passes_pct_short',\n", " 'vs_team_passes_pct_medium',\n", " 'vs_team_passes_pct_long',\n", " 'vs_team_sca_per90',\n", " 'vs_team_gca_per90',\n", " 'vs_team_dribble_tackles_pct',\n", " 'vs_team_dribbles_completed_pct',\n", " 'vs_team_aerials_won_pct',\n", " 'opp_team_possession',\n", " 'opp_team_goals_assists_per90',\n", " 'opp_team_goals_pens_per90',\n", " 'opp_team_goals_assists_pens_per90',\n", " 'opp_team_xg_per90',\n", " 'opp_team_gk_goals_against_per90',\n", " 'opp_team_gk_save_pct',\n", " 'opp_team_gk_clean_sheets_pct',\n", " 'opp_team_passes_pct',\n", " 'opp_team_passes_pct_medium',\n", " 'opp_team_passes_pct_long',\n", " 'opp_team_sca_per90',\n", " 'opp_team_gca_per90',\n", " 'opp_team_dribble_tackles_pct',\n", " 'opp_team_aerials_won_pct',\n", " 'opp_vs_team_possession',\n", " 'opp_vs_team_goals_per90',\n", " 'opp_vs_team_assists_per90',\n", " 'opp_vs_team_xg_per90',\n", " 'opp_vs_team_gk_save_pct',\n", " 'opp_vs_team_gk_clean_sheets_pct',\n", " 'opp_vs_team_gk_pct_passes_launched',\n", " 'opp_vs_team_gk_crosses_stopped_pct',\n", " 'opp_vs_team_shots_on_target_per90',\n", " 'opp_vs_team_passes_pct',\n", " 'opp_vs_team_passes_pct_short',\n", " 'opp_vs_team_passes_pct_medium',\n", " 'opp_vs_team_passes_pct_long',\n", " 'opp_vs_team_sca_per90',\n", " 'opp_vs_team_gca_per90',\n", " 'opp_vs_team_dribble_tackles_pct',\n", " 'opp_vs_team_dribbles_completed_pct',\n", " 'opp_vs_team_aerials_won_pct',\n", " \n", " 'vote_avg',\n", " 'vote_std']\n", "\n", "features_rel_gk = [\n", " 'gk_shots_on_target_against',\n", " 'gk_saves',\n", " 'gk_free_kick_goals_against',\n", " 'gk_corner_kick_goals_against',\n", " 'gk_own_goals_against',\n", " 'gk_psxg',\n", " 'gk_psnpxg_per_shot_on_target_against',\n", " 'gk_psxg_net',\n", " 'gk_passes_completed_launched',\n", " 'gk_passes_launched',\n", " 'gk_passes',\n", " 'gk_passes_throws',\n", " 'gk_goal_kicks',\n", " 'gk_crosses',\n", " 'gk_crosses_stopped',\n", "]" ] }, { "cell_type": "code", "execution_count": 25, "id": "5e3694a0", "metadata": {}, "outputs": [], "source": [ "def player_match_data_ext_gk(player, pteam, oppteam):\n", " pdata = player_match_data(player, pteam, oppteam)\n", " \n", " if(not isinstance(pdata, pd.DataFrame)):\n", " return None\n", " \n", " if(pdata['gk_games'][0] <= 0):\n", " return None\n", " \n", " out = pd.concat([pdata[features_abs_gk], pdata[features_rel_gk]], axis = 1)\n", " \n", " out[features_rel_gk] = out[features_rel_gk] / max(pdata['minutes'][0], 1)\n", "\n", " return out\n", " " ] }, { "cell_type": "code", "execution_count": 26, "id": "9b671646", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gk_gamesgk_games_startsgk_minutesgk_goals_against_per90gk_save_pctgk_clean_sheets_pctgk_psxg_net_per90gk_passes_pct_launchedgk_pct_passes_launchedgk_passes_length_avg...gk_psxggk_psnpxg_per_shot_on_target_againstgk_psxg_netgk_passes_completed_launchedgk_passes_launchedgk_passesgk_passes_throwsgk_goal_kicksgk_crossesgk_crosses_stopped
Consigli18.018.01620.01.5656.927.8-0.2942.131.834.6...22.80.36-5.2110.0261.0651.095.0167.0236.014.0
\n", "

1 rows × 98 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 18.0 18.0 1620.0 1.56 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 56.9 27.8 -0.29 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 42.1 31.8 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 34.6 ... 22.8 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.36 -5.2 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 110.0 261.0 651.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 95.0 167.0 236.0 14.0 \n", "\n", "[1 rows x 98 columns]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data_ext_gk('Consigli', 'Sassuolo', 'Atalanta')\n", "\n", "add_columns_gk = test.columns\n", "\n", "test" ] }, { "cell_type": "code", "execution_count": 27, "id": "33f805a9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "100\n", "200\n", "300\n", "400\n", "500\n", "600\n", "700\n", "800\n", "900\n", "1000\n", "1100\n", "1200\n", "1300\n", "1400\n", "1500\n", "1600\n", "1700\n", "1800\n", "1900\n", "2000\n", "2100\n", "2200\n", "2300\n", "2400\n", "2500\n", "2600\n", "2700\n", "2800\n", "2900\n", "3000\n", "3100\n", "3200\n", "3300\n", "3400\n", "3500\n", "3600\n", "3700\n", "3800\n", "3900\n", "4000\n", "4100\n", "4200\n", "4300\n", "4400\n", "4500\n", "4600\n", "4700\n", "4800\n", "4900\n", "5000\n", "5100\n", "5200\n", "5300\n", "5400\n", "5500\n", "5600\n", "5700\n" ] } ], "source": [ "db_gk = votes.copy()\n", "\n", "delta = pd.DataFrame(columns = add_columns_gk)\n", "\n", "for i in range(db_gk.shape[0]):\n", " ext_data = player_match_data_ext_gk(db_gk['player'][i], db_gk['team'][i], db_gk['oppteam'][i])\n", " \n", " if(i % 100 == 0):\n", " print(i)\n", " \n", " if(not isinstance(ext_data, pd.DataFrame)):\n", " continue\n", " \n", " ext_data = ext_data.rename(index = {db_gk['player'][i] : i})\n", " \n", " delta = pd.concat([delta, ext_data], axis = 0)\n", " \n", " \n", " \n", "db_gk = pd.concat([db_gk, delta], axis = 1)\n", " " ] }, { "cell_type": "code", "execution_count": 28, "id": "4d484846", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
matchdayplayerteamoppteamhomevotegoalsassistscards_malusfantavote...gk_psxggk_psnpxg_per_shot_on_target_againstgk_psxg_netgk_passes_completed_launchedgk_passes_launchedgk_passesgk_passes_throwsgk_goal_kicksgk_crossesgk_crosses_stopped
01MussoAtalantaSampdoria06.0000.55.5...11.10.22-1.979.0172.0340.098.092.0161.08.0
11ToloiAtalantaSampdoria07.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
21DjimsitiAtalantaSampdoria06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
31HateboerAtalantaSampdoria06.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
41OkoliAtalantaSampdoria05.5000.55.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
571020Sulemana I.VeronaUdinese05.5000.55.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
571120LasagnaVeronaUdinese05.5000.05.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
571220BraafVeronaUdinese05.0000.05.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
571320DjuricVeronaUdinese06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
571420NgongeVeronaUdinese06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

5715 rows × 108 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Sampdoria 0 6.0 0 0 \n", "1 1 Toloi Atalanta Sampdoria 0 7.0 1 0 \n", "2 1 Djimsiti Atalanta Sampdoria 0 6.0 0 0 \n", "3 1 Hateboer Atalanta Sampdoria 0 6.0 0 0 \n", "4 1 Okoli Atalanta Sampdoria 0 5.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "5710 20 Sulemana I. Verona Udinese 0 5.5 0 0 \n", "5711 20 Lasagna Verona Udinese 0 5.5 0 0 \n", "5712 20 Braaf Verona Udinese 0 5.0 0 0 \n", "5713 20 Djuric Verona Udinese 0 6.0 0 0 \n", "5714 20 Ngonge Verona Udinese 0 6.0 0 0 \n", "\n", " cards_malus fantavote ... gk_psxg \\\n", "0 0.5 5.5 ... 11.1 \n", "1 0.0 10.0 ... NaN \n", "2 0.0 6.0 ... NaN \n", "3 0.5 5.5 ... NaN \n", "4 0.5 5.0 ... NaN \n", "... ... ... ... ... \n", "5710 0.5 5.0 ... NaN \n", "5711 0.0 5.5 ... NaN \n", "5712 0.0 5.0 ... NaN \n", "5713 0.0 6.0 ... NaN \n", "5714 0.0 6.0 ... NaN \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.22 -1.9 \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "... ... ... \n", "5710 NaN NaN \n", "5711 NaN NaN \n", "5712 NaN NaN \n", "5713 NaN NaN \n", "5714 NaN NaN \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 79.0 172.0 340.0 \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "5710 NaN NaN NaN \n", "5711 NaN NaN NaN \n", "5712 NaN NaN NaN \n", "5713 NaN NaN NaN \n", "5714 NaN NaN NaN \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 98.0 92.0 161.0 8.0 \n", "1 NaN NaN NaN NaN \n", "2 NaN NaN NaN NaN \n", "3 NaN NaN NaN NaN \n", "4 NaN NaN NaN NaN \n", "... ... ... ... ... \n", "5710 NaN NaN NaN NaN \n", "5711 NaN NaN NaN NaN \n", "5712 NaN NaN NaN NaN \n", "5713 NaN NaN NaN NaN \n", "5714 NaN NaN NaN NaN \n", "\n", "[5715 rows x 108 columns]" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db_gk" ] }, { "cell_type": "code", "execution_count": 29, "id": "adab3577", "metadata": {}, "outputs": [], "source": [ "db_gk = db_gk.drop(db_gk[db_gk.gk_games != db_gk.gk_games].index) # remove non extisting players" ] }, { "cell_type": "code", "execution_count": 30, "id": "e7ae792d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
matchdayplayerteamoppteamhomevotegoalsassistscards_malusfantavote...gk_psxggk_psnpxg_per_shot_on_target_againstgk_psxg_netgk_passes_completed_launchedgk_passes_launchedgk_passesgk_passes_throwsgk_goal_kicksgk_crossesgk_crosses_stopped
01MussoAtalantaSampdoria06.0000.55.5...11.100.220-1.9079.0172.0340.098.092.0161.08.0
151SkorupskiBolognaLazio06.5-200.04.5...28.700.2800.7086.0220.0545.0116.0141.0280.018.0
441VicarioEmpoliSpezia05.5-100.04.5...25.000.2701.00101.0307.0740.0112.0107.0412.025.0
571GolliniFiorentinaCremonese15.0-200.03.0...9.150.2450.6523.566.5279.544.564.5118.53.5
711HandanovicInterLecce06.5-100.05.5...10.600.300-1.4027.052.0266.046.045.079.02.0
..................................................................
564520ConsigliSassuoloMilan06.0-200.04.0...22.800.360-5.20110.0261.0651.095.0167.0236.014.0
565820DragowskiSpeziaBologna06.5-200.04.5...26.000.280-3.0085.0255.0479.087.0106.0235.09.0
567320Milinkovic-Savic V.TorinoEmpoli05.5-200.03.5...21.300.240-0.70145.0510.0763.087.0149.0244.018.0
568820SilvestriUdineseVerona16.0-100.05.0...22.600.3201.6083.0211.0432.074.0154.0263.05.0
570020Montipo'VeronaUdinese06.5-100.05.5...26.800.250-4.20187.0374.0462.064.0159.0279.012.0
\n", "

395 rows × 108 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals \\\n", "0 1 Musso Atalanta Sampdoria 0 6.0 0 \n", "15 1 Skorupski Bologna Lazio 0 6.5 -2 \n", "44 1 Vicario Empoli Spezia 0 5.5 -1 \n", "57 1 Gollini Fiorentina Cremonese 1 5.0 -2 \n", "71 1 Handanovic Inter Lecce 0 6.5 -1 \n", "... ... ... ... ... ... ... ... \n", "5645 20 Consigli Sassuolo Milan 0 6.0 -2 \n", "5658 20 Dragowski Spezia Bologna 0 6.5 -2 \n", "5673 20 Milinkovic-Savic V. Torino Empoli 0 5.5 -2 \n", "5688 20 Silvestri Udinese Verona 1 6.0 -1 \n", "5700 20 Montipo' Verona Udinese 0 6.5 -1 \n", "\n", " assists cards_malus fantavote ... gk_psxg \\\n", "0 0 0.5 5.5 ... 11.10 \n", "15 0 0.0 4.5 ... 28.70 \n", "44 0 0.0 4.5 ... 25.00 \n", "57 0 0.0 3.0 ... 9.15 \n", "71 0 0.0 5.5 ... 10.60 \n", "... ... ... ... ... ... \n", "5645 0 0.0 4.0 ... 22.80 \n", "5658 0 0.0 4.5 ... 26.00 \n", "5673 0 0.0 3.5 ... 21.30 \n", "5688 0 0.0 5.0 ... 22.60 \n", "5700 0 0.0 5.5 ... 26.80 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.220 -1.90 \n", "15 0.280 0.70 \n", "44 0.270 1.00 \n", "57 0.245 0.65 \n", "71 0.300 -1.40 \n", "... ... ... \n", "5645 0.360 -5.20 \n", "5658 0.280 -3.00 \n", "5673 0.240 -0.70 \n", "5688 0.320 1.60 \n", "5700 0.250 -4.20 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 79.0 172.0 340.0 \n", "15 86.0 220.0 545.0 \n", "44 101.0 307.0 740.0 \n", "57 23.5 66.5 279.5 \n", "71 27.0 52.0 266.0 \n", "... ... ... ... \n", "5645 110.0 261.0 651.0 \n", "5658 85.0 255.0 479.0 \n", "5673 145.0 510.0 763.0 \n", "5688 83.0 211.0 432.0 \n", "5700 187.0 374.0 462.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 98.0 92.0 161.0 8.0 \n", "15 116.0 141.0 280.0 18.0 \n", "44 112.0 107.0 412.0 25.0 \n", "57 44.5 64.5 118.5 3.5 \n", "71 46.0 45.0 79.0 2.0 \n", "... ... ... ... ... \n", "5645 95.0 167.0 236.0 14.0 \n", "5658 87.0 106.0 235.0 9.0 \n", "5673 87.0 149.0 244.0 18.0 \n", "5688 74.0 154.0 263.0 5.0 \n", "5700 64.0 159.0 279.0 12.0 \n", "\n", "[395 rows x 108 columns]" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db_gk" ] }, { "cell_type": "markdown", "id": "8dbb7476", "metadata": {}, "source": [ "Save goalkeepers players database to file." ] }, { "cell_type": "code", "execution_count": 31, "id": "d8b8b6da", "metadata": {}, "outputs": [], "source": [ "db_gk.to_excel('mid_outputs/database_entries_gk.xlsx')" ] }, { "cell_type": "code", "execution_count": 32, "id": "54519b24", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 - matchday\n", "1 - player\n", "2 - team\n", "3 - oppteam\n", "4 - home\n", "5 - vote\n", "6 - goals\n", "7 - assists\n", "8 - cards_malus\n", "9 - fantavote\n", "10 - gk_games\n", "11 - gk_games_starts\n", "12 - gk_minutes\n", "13 - gk_goals_against_per90\n", "14 - gk_save_pct\n", "15 - gk_clean_sheets_pct\n", "16 - gk_psxg_net_per90\n", "17 - gk_passes_pct_launched\n", "18 - gk_pct_passes_launched\n", "19 - gk_passes_length_avg\n", "20 - gk_pct_goal_kicks_launched\n", "21 - gk_goal_kick_length_avg\n", "22 - gk_crosses_stopped_pct\n", "23 - gk_def_actions_outside_pen_area_per90\n", "24 - gk_avg_distance_def_actions\n", "25 - team_possession\n", "26 - team_goals_assists_per90\n", "27 - team_goals_pens_per90\n", "28 - team_goals_assists_pens_per90\n", "29 - team_xg_per90\n", "30 - team_gk_goals_against_per90\n", "31 - team_gk_save_pct\n", "32 - team_gk_clean_sheets_pct\n", "33 - team_passes_pct\n", "34 - team_passes_pct_medium\n", "35 - team_passes_pct_long\n", "36 - team_sca_per90\n", "37 - team_gca_per90\n", "38 - team_dribble_tackles_pct\n", "39 - team_aerials_won_pct\n", "40 - vs_team_possession\n", "41 - vs_team_goals_per90\n", "42 - vs_team_assists_per90\n", "43 - vs_team_xg_per90\n", "44 - vs_team_gk_save_pct\n", "45 - vs_team_gk_clean_sheets_pct\n", "46 - vs_team_gk_pct_passes_launched\n", "47 - vs_team_gk_crosses_stopped_pct\n", "48 - vs_team_shots_on_target_per90\n", "49 - vs_team_passes_pct\n", "50 - vs_team_passes_pct_short\n", "51 - vs_team_passes_pct_medium\n", "52 - vs_team_passes_pct_long\n", "53 - vs_team_sca_per90\n", "54 - vs_team_gca_per90\n", "55 - vs_team_dribble_tackles_pct\n", "56 - vs_team_dribbles_completed_pct\n", "57 - vs_team_aerials_won_pct\n", "58 - opp_team_possession\n", "59 - opp_team_goals_assists_per90\n", "60 - opp_team_goals_pens_per90\n", "61 - opp_team_goals_assists_pens_per90\n", "62 - opp_team_xg_per90\n", "63 - opp_team_gk_goals_against_per90\n", "64 - opp_team_gk_save_pct\n", "65 - opp_team_gk_clean_sheets_pct\n", "66 - opp_team_passes_pct\n", "67 - opp_team_passes_pct_medium\n", "68 - opp_team_passes_pct_long\n", "69 - opp_team_sca_per90\n", "70 - opp_team_gca_per90\n", "71 - opp_team_dribble_tackles_pct\n", "72 - opp_team_aerials_won_pct\n", "73 - opp_vs_team_possession\n", "74 - opp_vs_team_goals_per90\n", "75 - opp_vs_team_assists_per90\n", "76 - opp_vs_team_xg_per90\n", "77 - opp_vs_team_gk_save_pct\n", "78 - opp_vs_team_gk_clean_sheets_pct\n", "79 - opp_vs_team_gk_pct_passes_launched\n", "80 - opp_vs_team_gk_crosses_stopped_pct\n", "81 - opp_vs_team_shots_on_target_per90\n", "82 - opp_vs_team_passes_pct\n", "83 - opp_vs_team_passes_pct_short\n", "84 - opp_vs_team_passes_pct_medium\n", "85 - opp_vs_team_passes_pct_long\n", "86 - opp_vs_team_sca_per90\n", "87 - opp_vs_team_gca_per90\n", "88 - opp_vs_team_dribble_tackles_pct\n", "89 - opp_vs_team_dribbles_completed_pct\n", "90 - opp_vs_team_aerials_won_pct\n", "91 - vote_avg\n", "92 - vote_std\n", "93 - gk_shots_on_target_against\n", "94 - gk_saves\n", "95 - gk_free_kick_goals_against\n", "96 - gk_corner_kick_goals_against\n", "97 - gk_own_goals_against\n", "98 - gk_psxg\n", "99 - gk_psnpxg_per_shot_on_target_against\n", "100 - gk_psxg_net\n", "101 - gk_passes_completed_launched\n", "102 - gk_passes_launched\n", "103 - gk_passes\n", "104 - gk_passes_throws\n", "105 - gk_goal_kicks\n", "106 - gk_crosses\n", "107 - gk_crosses_stopped\n" ] } ], "source": [ "for i in range(db_gk.columns.shape[0]):\n", " print(str(i) + \" - \" + str(db_gk.columns[i]))" ] }, { "cell_type": "code", "execution_count": null, "id": "b0209868", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }