{ "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": 29, "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": 30, "id": "8a6867a5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7952\\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.048.419.0209.01710.036.025.06.08.0...209.0218.025.01.08.01.01165.0239.0279.046.1
BolognaBologna24.052.620.0220.01800.025.019.03.03.0...252.0229.033.03.03.01.01081.0224.0180.055.4
CremoneseCremonese29.044.019.0209.01710.014.06.02.04.0...205.0247.029.03.04.00.01052.0348.0267.056.6
EmpoliEmpoli26.046.319.0209.01710.017.09.00.00.0...251.0214.031.02.00.00.0999.0217.0189.053.4
FiorentinaFiorentina27.057.219.0209.01710.021.017.02.04.0...259.0229.052.01.04.00.0942.0249.0289.046.3
VeronaHellas Verona29.043.419.0209.01710.016.013.00.00.0...192.0276.022.01.00.01.01038.0345.0388.047.1
InterInter23.052.919.0209.01710.037.025.02.02.0...242.0214.018.02.02.01.0869.0198.0232.046.0
JuventusJuventus26.049.519.0209.01710.030.023.02.03.0...210.0210.025.00.03.00.0947.0230.0230.050.0
LazioLazio21.051.219.0209.01710.034.025.03.04.0...261.0185.042.01.04.01.01021.0183.0181.050.3
LecceLecce26.042.520.0220.01800.018.012.01.02.0...263.0265.043.03.02.01.01072.0373.0294.055.9
MilanMilan27.054.519.0209.01710.033.028.02.02.0...234.0226.020.03.02.02.0964.0224.0275.044.9
MonzaMonza29.055.119.0209.01710.022.013.03.03.0...279.0242.034.00.03.01.0958.0197.0215.047.8
NapoliNapoli24.061.319.0209.01710.046.037.04.05.0...258.0167.027.01.04.00.0933.0201.0231.046.5
RomaRoma25.049.419.0209.01710.025.016.03.05.0...266.0214.010.00.05.00.0981.0184.0225.045.0
SalernitanaSalernitana28.044.820.0220.01800.024.016.01.01.0...226.0233.049.07.01.01.01084.0257.0240.051.7
SampdoriaSampdoria29.049.419.0209.01710.08.07.00.00.0...299.0266.055.03.00.00.01017.0300.0318.048.5
SassuoloSassuolo27.048.719.0209.01710.018.013.03.04.0...249.0182.062.02.04.00.0986.0216.0173.055.5
SpeziaSpezia30.046.720.0220.01800.015.010.02.02.0...207.0261.046.01.02.02.01182.0322.0281.053.4
TorinoTorino23.052.819.0209.01710.019.014.01.01.0...209.0265.021.03.01.00.0998.0323.0295.052.3
UdineseUdinese22.050.119.0209.01710.026.022.00.00.0...250.0227.029.02.00.01.0950.0189.0237.044.4
\n", "

20 rows × 313 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 24.0 48.4 19.0 \n", "Bologna Bologna 24.0 52.6 20.0 \n", "Cremonese Cremonese 29.0 44.0 19.0 \n", "Empoli Empoli 26.0 46.3 19.0 \n", "Fiorentina Fiorentina 27.0 57.2 19.0 \n", "Verona Hellas Verona 29.0 43.4 19.0 \n", "Inter Inter 23.0 52.9 19.0 \n", "Juventus Juventus 26.0 49.5 19.0 \n", "Lazio Lazio 21.0 51.2 19.0 \n", "Lecce Lecce 26.0 42.5 20.0 \n", "Milan Milan 27.0 54.5 19.0 \n", "Monza Monza 29.0 55.1 19.0 \n", "Napoli Napoli 24.0 61.3 19.0 \n", "Roma Roma 25.0 49.4 19.0 \n", "Salernitana Salernitana 28.0 44.8 20.0 \n", "Sampdoria Sampdoria 29.0 49.4 19.0 \n", "Sassuolo Sassuolo 27.0 48.7 19.0 \n", "Spezia Spezia 30.0 46.7 20.0 \n", "Torino Torino 23.0 52.8 19.0 \n", "Udinese Udinese 22.0 50.1 19.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 209.0 1710.0 36.0 25.0 \n", "Bologna 220.0 1800.0 25.0 19.0 \n", "Cremonese 209.0 1710.0 14.0 6.0 \n", "Empoli 209.0 1710.0 17.0 9.0 \n", "Fiorentina 209.0 1710.0 21.0 17.0 \n", "Verona 209.0 1710.0 16.0 13.0 \n", "Inter 209.0 1710.0 37.0 25.0 \n", "Juventus 209.0 1710.0 30.0 23.0 \n", "Lazio 209.0 1710.0 34.0 25.0 \n", "Lecce 220.0 1800.0 18.0 12.0 \n", "Milan 209.0 1710.0 33.0 28.0 \n", "Monza 209.0 1710.0 22.0 13.0 \n", "Napoli 209.0 1710.0 46.0 37.0 \n", "Roma 209.0 1710.0 25.0 16.0 \n", "Salernitana 220.0 1800.0 24.0 16.0 \n", "Sampdoria 209.0 1710.0 8.0 7.0 \n", "Sassuolo 209.0 1710.0 18.0 13.0 \n", "Spezia 220.0 1800.0 15.0 10.0 \n", "Torino 209.0 1710.0 19.0 14.0 \n", "Udinese 209.0 1710.0 26.0 22.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls \\\n", "team_idx ... \n", "Atalanta 6.0 8.0 ... 209.0 \n", "Bologna 3.0 3.0 ... 252.0 \n", "Cremonese 2.0 4.0 ... 205.0 \n", "Empoli 0.0 0.0 ... 251.0 \n", "Fiorentina 2.0 4.0 ... 259.0 \n", "Verona 0.0 0.0 ... 192.0 \n", "Inter 2.0 2.0 ... 242.0 \n", "Juventus 2.0 3.0 ... 210.0 \n", "Lazio 3.0 4.0 ... 261.0 \n", "Lecce 1.0 2.0 ... 263.0 \n", "Milan 2.0 2.0 ... 234.0 \n", "Monza 3.0 3.0 ... 279.0 \n", "Napoli 4.0 5.0 ... 258.0 \n", "Roma 3.0 5.0 ... 266.0 \n", "Salernitana 1.0 1.0 ... 226.0 \n", "Sampdoria 0.0 0.0 ... 299.0 \n", "Sassuolo 3.0 4.0 ... 249.0 \n", "Spezia 2.0 2.0 ... 207.0 \n", "Torino 1.0 1.0 ... 209.0 \n", "Udinese 0.0 0.0 ... 250.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 218.0 25.0 1.0 \n", "Bologna 229.0 33.0 3.0 \n", "Cremonese 247.0 29.0 3.0 \n", "Empoli 214.0 31.0 2.0 \n", "Fiorentina 229.0 52.0 1.0 \n", "Verona 276.0 22.0 1.0 \n", "Inter 214.0 18.0 2.0 \n", "Juventus 210.0 25.0 0.0 \n", "Lazio 185.0 42.0 1.0 \n", "Lecce 265.0 43.0 3.0 \n", "Milan 226.0 20.0 3.0 \n", "Monza 242.0 34.0 0.0 \n", "Napoli 167.0 27.0 1.0 \n", "Roma 214.0 10.0 0.0 \n", "Salernitana 233.0 49.0 7.0 \n", "Sampdoria 266.0 55.0 3.0 \n", "Sassuolo 182.0 62.0 2.0 \n", "Spezia 261.0 46.0 1.0 \n", "Torino 265.0 21.0 3.0 \n", "Udinese 227.0 29.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 1.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 4.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 1165.0 239.0 \n", "Bologna 1081.0 224.0 \n", "Cremonese 1052.0 348.0 \n", "Empoli 999.0 217.0 \n", "Fiorentina 942.0 249.0 \n", "Verona 1038.0 345.0 \n", "Inter 869.0 198.0 \n", "Juventus 947.0 230.0 \n", "Lazio 1021.0 183.0 \n", "Lecce 1072.0 373.0 \n", "Milan 964.0 224.0 \n", "Monza 958.0 197.0 \n", "Napoli 933.0 201.0 \n", "Roma 981.0 184.0 \n", "Salernitana 1084.0 257.0 \n", "Sampdoria 1017.0 300.0 \n", "Sassuolo 986.0 216.0 \n", "Spezia 1182.0 322.0 \n", "Torino 998.0 323.0 \n", "Udinese 950.0 189.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 279.0 46.1 \n", "Bologna 180.0 55.4 \n", "Cremonese 267.0 56.6 \n", "Empoli 189.0 53.4 \n", "Fiorentina 289.0 46.3 \n", "Verona 388.0 47.1 \n", "Inter 232.0 46.0 \n", "Juventus 230.0 50.0 \n", "Lazio 181.0 50.3 \n", "Lecce 294.0 55.9 \n", "Milan 275.0 44.9 \n", "Monza 215.0 47.8 \n", "Napoli 231.0 46.5 \n", "Roma 225.0 45.0 \n", "Salernitana 240.0 51.7 \n", "Sampdoria 318.0 48.5 \n", "Sassuolo 173.0 55.5 \n", "Spezia 281.0 53.4 \n", "Torino 295.0 52.3 \n", "Udinese 237.0 44.4 \n", "\n", "[20 rows x 313 columns]" ] }, "execution_count": 30, "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": 31, "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": 32, "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
Meret0572PNapoliMeretNaN52925-31219970...20.227.1197.06.03.023.01.2117.26.2631580.496525
Provedel12814PLazioProvedelNaN53828-31719940...34.834.8256.07.02.737.01.9618.16.2368420.339055
Vicario24964PEmpoliVicarioNaN54726-11319960...45.641.8399.025.06.38.00.4210.56.4736840.379532
Szczesny3453PJuventusSzczesnyNaN54432-28519900...41.039.2155.04.02.67.00.5614.26.0384620.364878
Falcone42134PLecceFalconeNaN52427-29119950...75.051.4304.013.04.320.01.0012.56.3421050.364642
..................................................................
Kaio Jorge5425505AJuventusJorgeNaN-1000...0.00.00.00.00.00.00.000.06.0922800.894197
De Luca5435512ASampdoriaLucaNaN12824-19519981...0.00.00.00.00.00.00.000.06.2849270.532298
Lazetic5445785AMilanLazeticNaN25819-00620041...0.00.00.00.00.00.00.000.06.0940040.625570
Montevago5456113ASampdoriaMontevagoNaN31819-31620036...0.00.00.00.00.00.00.000.05.7119340.225193
Krollis5466143ASpeziaKrollisNaN-1000...0.00.00.00.00.00.00.000.05.7488950.595450
\n", "

547 rows × 165 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "name \n", "Meret 0 572 P Napoli Meret NaN 529 25-312 \n", "Provedel 1 2814 P Lazio Provedel NaN 538 28-317 \n", "Vicario 2 4964 P Empoli Vicario NaN 547 26-113 \n", "Szczesny 3 453 P Juventus Szczesny NaN 544 32-285 \n", "Falcone 4 2134 P Lecce Falcone NaN 524 27-291 \n", "... ... ... .. ... ... ... ... ... \n", "Kaio Jorge 542 5505 A Juventus Jorge NaN -1 0 \n", "De Luca 543 5512 A Sampdoria Luca NaN 128 24-195 \n", "Lazetic 544 5785 A Milan Lazetic NaN 258 19-006 \n", "Montevago 545 6113 A Sampdoria Montevago NaN 318 19-316 \n", "Krollis 546 6143 A Spezia Krollis NaN -1 0 \n", "\n", " birth_year games ... gk_pct_goal_kicks_launched \\\n", "name ... \n", "Meret 1997 0 ... 20.2 \n", "Provedel 1994 0 ... 34.8 \n", "Vicario 1996 0 ... 45.6 \n", "Szczesny 1990 0 ... 41.0 \n", "Falcone 1995 0 ... 75.0 \n", "... ... ... ... ... \n", "Kaio Jorge 0 0 ... 0.0 \n", "De Luca 1998 1 ... 0.0 \n", "Lazetic 2004 1 ... 0.0 \n", "Montevago 2003 6 ... 0.0 \n", "Krollis 0 0 ... 0.0 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "name \n", "Meret 27.1 197.0 6.0 \n", "Provedel 34.8 256.0 7.0 \n", "Vicario 41.8 399.0 25.0 \n", "Szczesny 39.2 155.0 4.0 \n", "Falcone 51.4 304.0 13.0 \n", "... ... ... ... \n", "Kaio Jorge 0.0 0.0 0.0 \n", "De Luca 0.0 0.0 0.0 \n", "Lazetic 0.0 0.0 0.0 \n", "Montevago 0.0 0.0 0.0 \n", "Krollis 0.0 0.0 0.0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "name \n", "Meret 3.0 23.0 \n", "Provedel 2.7 37.0 \n", "Vicario 6.3 8.0 \n", "Szczesny 2.6 7.0 \n", "Falcone 4.3 20.0 \n", "... ... ... \n", "Kaio Jorge 0.0 0.0 \n", "De Luca 0.0 0.0 \n", "Lazetic 0.0 0.0 \n", "Montevago 0.0 0.0 \n", "Krollis 0.0 0.0 \n", "\n", " gk_def_actions_outside_pen_area_per90 \\\n", "name \n", "Meret 1.21 \n", "Provedel 1.96 \n", "Vicario 0.42 \n", "Szczesny 0.56 \n", "Falcone 1.00 \n", "... ... \n", "Kaio Jorge 0.00 \n", "De Luca 0.00 \n", "Lazetic 0.00 \n", "Montevago 0.00 \n", "Krollis 0.00 \n", "\n", " gk_avg_distance_def_actions vote_avg vote_std \n", "name \n", "Meret 17.2 6.263158 0.496525 \n", "Provedel 18.1 6.236842 0.339055 \n", "Vicario 10.5 6.473684 0.379532 \n", "Szczesny 14.2 6.038462 0.364878 \n", "Falcone 12.5 6.342105 0.364642 \n", "... ... ... ... \n", "Kaio Jorge 0.0 6.092280 0.894197 \n", "De Luca 0.0 6.284927 0.532298 \n", "Lazetic 0.0 6.094004 0.625570 \n", "Montevago 0.0 5.711934 0.225193 \n", "Krollis 0.0 5.748895 0.595450 \n", "\n", "[547 rows x 165 columns]" ] }, "execution_count": 32, "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": 33, "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": 34, "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
Frattesi2762848CSassuoloFrattesiNaN18423-098199919...209.0218.025.01.08.01.01165.0239.0279.046.1
\n", "

1 rows × 791 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "Frattesi 276 2848 C Sassuolo Frattesi NaN 184 23-098 \n", "\n", " birth_year games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Frattesi 1999 19 ... 209.0 218.0 \n", "\n", " opp_vs_team_offsides opp_vs_team_pens_won \\\n", "Frattesi 25.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 1165.0 239.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Frattesi 279.0 46.1 \n", "\n", "[1 rows x 791 columns]" ] }, "execution_count": 34, "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": 35, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Sassuolo'" ] }, "execution_count": 35, "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": 36, "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", " '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": 36, "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": 37, "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", "\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": 38, "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": 39, "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...touches_live_balldribbles_completeddribblespasses_receivedmiscontrolsdispossessedfoulsfouledaerials_wonaerials_lost
FrattesiC1919156048.60.110.2477.954.554.5...0.4820510.0153850.0282050.3224360.0166670.0173080.0147440.0230770.0102560.007051
\n", "

1 rows × 121 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct \\\n", "Frattesi C 19 19 1560 48.6 \n", "\n", " goals_per_shot goals_per_shot_on_target passes_pct \\\n", "Frattesi 0.11 0.24 77.9 \n", "\n", " dribble_tackles_pct dribbles_completed_pct ... touches_live_ball \\\n", "Frattesi 54.5 54.5 ... 0.482051 \n", "\n", " dribbles_completed dribbles passes_received miscontrols \\\n", "Frattesi 0.015385 0.028205 0.322436 0.016667 \n", "\n", " dispossessed fouls fouled aerials_won aerials_lost \n", "Frattesi 0.017308 0.014744 0.023077 0.010256 0.007051 \n", "\n", "[1 rows x 121 columns]" ] }, "execution_count": 39, "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": 40, "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
.................................
542319IlicVeronaLecce17.0010.08.0
542419Sulemana I.VeronaLecce16.0000.06.0
542519LasagnaVeronaLecce15.5000.05.5
542619KallonVeronaLecce16.0000.06.0
542719DjuricVeronaLecce16.0000.06.0
\n", "

5428 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", "5423 19 Ilic Verona Lecce 1 7.0 0 1 \n", "5424 19 Sulemana I. Verona Lecce 1 6.0 0 0 \n", "5425 19 Lasagna Verona Lecce 1 5.5 0 0 \n", "5426 19 Kallon Verona Lecce 1 6.0 0 0 \n", "5427 19 Djuric Verona Lecce 1 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", "5423 0.0 8.0 \n", "5424 0.0 6.0 \n", "5425 0.0 5.5 \n", "5426 0.0 6.0 \n", "5427 0.0 6.0 \n", "\n", "[5428 rows x 10 columns]" ] }, "execution_count": 40, "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": 41, "id": "ec0bc56b", "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", "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" ] } ], "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": 42, "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...touches_live_balldribbles_completeddribblespasses_receivedmiscontrolsdispossessedfoulsfouledaerials_wonaerials_lost
01MussoAtalantaSampdoria06.0000.55.5...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
11ToloiAtalantaSampdoria07.0100.010.0...0.6842110.0008490.0050930.4074700.0076400.0008490.0067910.0050930.0161290.011885
21DjimsitiAtalantaSampdoria06.0000.06.0...0.7535410.0000000.0028330.5212460.0028330.0084990.0028330.0028330.0056660.008499
31HateboerAtalantaSampdoria06.0000.55.5...0.5860900.0033930.0067850.3570820.0067850.0042410.0127230.0016960.0152670.011874
41OkoliAtalantaSampdoria05.5000.55.0...0.6071010.0000000.0011830.2792900.0130180.0035500.0153850.0082840.0473370.027219
..................................................................
542319IlicVeronaLecce17.0010.08.0...0.5722680.0070510.0188010.2773210.0199760.0058750.0105760.0105760.0117510.015276
542419Sulemana I.VeronaLecce16.0000.06.0...0.4779660.0101690.0305080.2067800.0169490.0135590.0203390.0067800.0203390.027119
542519LasagnaVeronaLecce15.5000.05.5...0.3012820.0074790.0256410.1912390.0363250.0256410.0192310.0170940.0074790.032051
542619KallonVeronaLecce16.0000.06.0...0.4093100.0080260.0337080.2937400.0337080.0240770.0176570.0272870.0112360.025682
542719DjuricVeronaLecce16.0000.06.0...0.5161810.0016180.0048540.4514560.0275080.0064720.0242720.0210360.1666670.043689
\n", "

5428 rows × 131 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", "5423 19 Ilic Verona Lecce 1 7.0 0 1 \n", "5424 19 Sulemana I. Verona Lecce 1 6.0 0 0 \n", "5425 19 Lasagna Verona Lecce 1 5.5 0 0 \n", "5426 19 Kallon Verona Lecce 1 6.0 0 0 \n", "5427 19 Djuric Verona Lecce 1 6.0 0 0 \n", "\n", " cards_malus fantavote ... touches_live_ball dribbles_completed \\\n", "0 0.5 5.5 ... 0.000000 0.000000 \n", "1 0.0 10.0 ... 0.684211 0.000849 \n", "2 0.0 6.0 ... 0.753541 0.000000 \n", "3 0.5 5.5 ... 0.586090 0.003393 \n", "4 0.5 5.0 ... 0.607101 0.000000 \n", "... ... ... ... ... ... \n", "5423 0.0 8.0 ... 0.572268 0.007051 \n", "5424 0.0 6.0 ... 0.477966 0.010169 \n", "5425 0.0 5.5 ... 0.301282 0.007479 \n", "5426 0.0 6.0 ... 0.409310 0.008026 \n", "5427 0.0 6.0 ... 0.516181 0.001618 \n", "\n", " dribbles passes_received miscontrols dispossessed fouls fouled \\\n", "0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "1 0.005093 0.407470 0.007640 0.000849 0.006791 0.005093 \n", "2 0.002833 0.521246 0.002833 0.008499 0.002833 0.002833 \n", "3 0.006785 0.357082 0.006785 0.004241 0.012723 0.001696 \n", "4 0.001183 0.279290 0.013018 0.003550 0.015385 0.008284 \n", "... ... ... ... ... ... ... \n", "5423 0.018801 0.277321 0.019976 0.005875 0.010576 0.010576 \n", "5424 0.030508 0.206780 0.016949 0.013559 0.020339 0.006780 \n", "5425 0.025641 0.191239 0.036325 0.025641 0.019231 0.017094 \n", "5426 0.033708 0.293740 0.033708 0.024077 0.017657 0.027287 \n", "5427 0.004854 0.451456 0.027508 0.006472 0.024272 0.021036 \n", "\n", " aerials_won aerials_lost \n", "0 0.000000 0.000000 \n", "1 0.016129 0.011885 \n", "2 0.005666 0.008499 \n", "3 0.015267 0.011874 \n", "4 0.047337 0.027219 \n", "... ... ... \n", "5423 0.011751 0.015276 \n", "5424 0.020339 0.027119 \n", "5425 0.007479 0.032051 \n", "5426 0.011236 0.025682 \n", "5427 0.166667 0.043689 \n", "\n", "[5428 rows x 131 columns]" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "markdown", "id": "d237f87b", "metadata": {}, "source": [ "Remove undesired database entries." ] }, { "cell_type": "code", "execution_count": 43, "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": 44, "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...touches_live_balldribbles_completeddribblespasses_receivedmiscontrolsdispossessedfoulsfouledaerials_wonaerials_lost
11ToloiAtalantaSampdoria07.0100.010.0...0.6842110.0008490.0050930.4074700.0076400.0008490.0067910.0050930.0161290.011885
21DjimsitiAtalantaSampdoria06.0000.06.0...0.7535410.0000000.0028330.5212460.0028330.0084990.0028330.0028330.0056660.008499
31HateboerAtalantaSampdoria06.0000.55.5...0.5860900.0033930.0067850.3570820.0067850.0042410.0127230.0016960.0152670.011874
41OkoliAtalantaSampdoria05.5000.55.0...0.6071010.0000000.0011830.2792900.0130180.0035500.0153850.0082840.0473370.027219
51ZorteaAtalantaSampdoria06.0000.55.5...0.6486490.0450450.0945950.3648650.0270270.0090090.0180180.0000000.0225230.004505
..................................................................
542319IlicVeronaLecce17.0010.08.0...0.5722680.0070510.0188010.2773210.0199760.0058750.0105760.0105760.0117510.015276
542419Sulemana I.VeronaLecce16.0000.06.0...0.4779660.0101690.0305080.2067800.0169490.0135590.0203390.0067800.0203390.027119
542519LasagnaVeronaLecce15.5000.05.5...0.3012820.0074790.0256410.1912390.0363250.0256410.0192310.0170940.0074790.032051
542619KallonVeronaLecce16.0000.06.0...0.4093100.0080260.0337080.2937400.0337080.0240770.0176570.0272870.0112360.025682
542719DjuricVeronaLecce16.0000.06.0...0.5161810.0016180.0048540.4514560.0275080.0064720.0242720.0210360.1666670.043689
\n", "

4906 rows × 131 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", "5423 19 Ilic Verona Lecce 1 7.0 0 1 \n", "5424 19 Sulemana I. Verona Lecce 1 6.0 0 0 \n", "5425 19 Lasagna Verona Lecce 1 5.5 0 0 \n", "5426 19 Kallon Verona Lecce 1 6.0 0 0 \n", "5427 19 Djuric Verona Lecce 1 6.0 0 0 \n", "\n", " cards_malus fantavote ... touches_live_ball dribbles_completed \\\n", "1 0.0 10.0 ... 0.684211 0.000849 \n", "2 0.0 6.0 ... 0.753541 0.000000 \n", "3 0.5 5.5 ... 0.586090 0.003393 \n", "4 0.5 5.0 ... 0.607101 0.000000 \n", "5 0.5 5.5 ... 0.648649 0.045045 \n", "... ... ... ... ... ... \n", "5423 0.0 8.0 ... 0.572268 0.007051 \n", "5424 0.0 6.0 ... 0.477966 0.010169 \n", "5425 0.0 5.5 ... 0.301282 0.007479 \n", "5426 0.0 6.0 ... 0.409310 0.008026 \n", "5427 0.0 6.0 ... 0.516181 0.001618 \n", "\n", " dribbles passes_received miscontrols dispossessed fouls fouled \\\n", "1 0.005093 0.407470 0.007640 0.000849 0.006791 0.005093 \n", "2 0.002833 0.521246 0.002833 0.008499 0.002833 0.002833 \n", "3 0.006785 0.357082 0.006785 0.004241 0.012723 0.001696 \n", "4 0.001183 0.279290 0.013018 0.003550 0.015385 0.008284 \n", "5 0.094595 0.364865 0.027027 0.009009 0.018018 0.000000 \n", "... ... ... ... ... ... ... \n", "5423 0.018801 0.277321 0.019976 0.005875 0.010576 0.010576 \n", "5424 0.030508 0.206780 0.016949 0.013559 0.020339 0.006780 \n", "5425 0.025641 0.191239 0.036325 0.025641 0.019231 0.017094 \n", "5426 0.033708 0.293740 0.033708 0.024077 0.017657 0.027287 \n", "5427 0.004854 0.451456 0.027508 0.006472 0.024272 0.021036 \n", "\n", " aerials_won aerials_lost \n", "1 0.016129 0.011885 \n", "2 0.005666 0.008499 \n", "3 0.015267 0.011874 \n", "4 0.047337 0.027219 \n", "5 0.022523 0.004505 \n", "... ... ... \n", "5423 0.011751 0.015276 \n", "5424 0.020339 0.027119 \n", "5425 0.007479 0.032051 \n", "5426 0.011236 0.025682 \n", "5427 0.166667 0.043689 \n", "\n", "[4906 rows x 131 columns]" ] }, "execution_count": 44, "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": 45, "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": 46, "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": 47, "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": 47, "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": 48, "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": 49, "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": 50, "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
Consigli17.017.01530.01.5356.629.4-0.2641.330.934.4...21.60.37-4.4100.0242.0621.087.0157.0220.013.0
\n", "

1 rows × 98 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 17.0 17.0 1530.0 1.53 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 56.6 29.4 -0.26 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 41.3 30.9 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 34.4 ... 21.6 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.37 -4.4 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 100.0 242.0 621.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 87.0 157.0 220.0 13.0 \n", "\n", "[1 rows x 98 columns]" ] }, "execution_count": 50, "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": 51, "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" ] } ], "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": 52, "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...10.40.22-2.678.0167.0321.093.086.0147.08.0
11ToloiAtalantaSampdoria07.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
21DjimsitiAtalantaSampdoria06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
31HateboerAtalantaSampdoria06.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
41OkoliAtalantaSampdoria05.5000.55.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
542319IlicVeronaLecce17.0010.08.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
542419Sulemana I.VeronaLecce16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
542519LasagnaVeronaLecce15.5000.05.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
542619KallonVeronaLecce16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
542719DjuricVeronaLecce16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

5428 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", "5423 19 Ilic Verona Lecce 1 7.0 0 1 \n", "5424 19 Sulemana I. Verona Lecce 1 6.0 0 0 \n", "5425 19 Lasagna Verona Lecce 1 5.5 0 0 \n", "5426 19 Kallon Verona Lecce 1 6.0 0 0 \n", "5427 19 Djuric Verona Lecce 1 6.0 0 0 \n", "\n", " cards_malus fantavote ... gk_psxg \\\n", "0 0.5 5.5 ... 10.4 \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", "5423 0.0 8.0 ... NaN \n", "5424 0.0 6.0 ... NaN \n", "5425 0.0 5.5 ... NaN \n", "5426 0.0 6.0 ... NaN \n", "5427 0.0 6.0 ... NaN \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.22 -2.6 \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "... ... ... \n", "5423 NaN NaN \n", "5424 NaN NaN \n", "5425 NaN NaN \n", "5426 NaN NaN \n", "5427 NaN NaN \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 78.0 167.0 321.0 \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "5423 NaN NaN NaN \n", "5424 NaN NaN NaN \n", "5425 NaN NaN NaN \n", "5426 NaN NaN NaN \n", "5427 NaN NaN NaN \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 93.0 86.0 147.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", "5423 NaN NaN NaN NaN \n", "5424 NaN NaN NaN NaN \n", "5425 NaN NaN NaN NaN \n", "5426 NaN NaN NaN NaN \n", "5427 NaN NaN NaN NaN \n", "\n", "[5428 rows x 108 columns]" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db_gk" ] }, { "cell_type": "code", "execution_count": 53, "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": 54, "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...10.4000000.220000-2.60000078.000000167.000000321.00000093.00000086.0147.08.000000
151SkorupskiBolognaLazio06.5-200.04.5...28.7000000.2800000.70000087.000000219.000000545.000000116.000000141.0280.018.000000
441VicarioEmpoliSpezia05.5-100.04.5...24.0000000.2700002.00000088.000000277.000000690.000000108.000000103.0399.025.000000
571GolliniFiorentinaCremonese15.0-200.03.0...15.6000000.2700001.60000034.00000092.000000425.00000069.000000114.0197.06.000000
711HandanovicInterLecce06.5-100.05.5...10.6000000.300000-1.40000027.00000052.000000266.00000046.00000045.079.02.000000
..................................................................
536219PegoloSassuoloMonza06.5-100.05.5...15.4666670.373333-2.86666769.666667167.333333434.33333361.333333110.0156.09.333333
537419DragowskiSpeziaRoma16.0-200.04.0...26.0000000.280000-3.00000085.000000255.000000479.00000087.000000106.0235.09.000000
538819Milinkovic-Savic V.TorinoFiorentina07.0000.07.0...20.3000000.2400000.300000138.000000493.000000746.00000085.000000142.0232.018.000000
540119SilvestriUdineseSampdoria06.0000.06.0...22.1000000.3200001.10000076.000000200.000000406.00000072.000000153.0253.04.000000
541419Montipo'VeronaLecce16.5000.06.5...25.2000000.250000-4.800000176.000000358.000000447.00000062.000000153.0261.010.000000
\n", "

375 rows × 108 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote \\\n", "0 1 Musso Atalanta Sampdoria 0 6.0 \n", "15 1 Skorupski Bologna Lazio 0 6.5 \n", "44 1 Vicario Empoli Spezia 0 5.5 \n", "57 1 Gollini Fiorentina Cremonese 1 5.0 \n", "71 1 Handanovic Inter Lecce 0 6.5 \n", "... ... ... ... ... ... ... \n", "5362 19 Pegolo Sassuolo Monza 0 6.5 \n", "5374 19 Dragowski Spezia Roma 1 6.0 \n", "5388 19 Milinkovic-Savic V. Torino Fiorentina 0 7.0 \n", "5401 19 Silvestri Udinese Sampdoria 0 6.0 \n", "5414 19 Montipo' Verona Lecce 1 6.5 \n", "\n", " goals assists cards_malus fantavote ... gk_psxg \\\n", "0 0 0 0.5 5.5 ... 10.400000 \n", "15 -2 0 0.0 4.5 ... 28.700000 \n", "44 -1 0 0.0 4.5 ... 24.000000 \n", "57 -2 0 0.0 3.0 ... 15.600000 \n", "71 -1 0 0.0 5.5 ... 10.600000 \n", "... ... ... ... ... ... ... \n", "5362 -1 0 0.0 5.5 ... 15.466667 \n", "5374 -2 0 0.0 4.0 ... 26.000000 \n", "5388 0 0 0.0 7.0 ... 20.300000 \n", "5401 0 0 0.0 6.0 ... 22.100000 \n", "5414 0 0 0.0 6.5 ... 25.200000 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.220000 -2.600000 \n", "15 0.280000 0.700000 \n", "44 0.270000 2.000000 \n", "57 0.270000 1.600000 \n", "71 0.300000 -1.400000 \n", "... ... ... \n", "5362 0.373333 -2.866667 \n", "5374 0.280000 -3.000000 \n", "5388 0.240000 0.300000 \n", "5401 0.320000 1.100000 \n", "5414 0.250000 -4.800000 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 78.000000 167.000000 321.000000 \n", "15 87.000000 219.000000 545.000000 \n", "44 88.000000 277.000000 690.000000 \n", "57 34.000000 92.000000 425.000000 \n", "71 27.000000 52.000000 266.000000 \n", "... ... ... ... \n", "5362 69.666667 167.333333 434.333333 \n", "5374 85.000000 255.000000 479.000000 \n", "5388 138.000000 493.000000 746.000000 \n", "5401 76.000000 200.000000 406.000000 \n", "5414 176.000000 358.000000 447.000000 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 93.000000 86.0 147.0 8.000000 \n", "15 116.000000 141.0 280.0 18.000000 \n", "44 108.000000 103.0 399.0 25.000000 \n", "57 69.000000 114.0 197.0 6.000000 \n", "71 46.000000 45.0 79.0 2.000000 \n", "... ... ... ... ... \n", "5362 61.333333 110.0 156.0 9.333333 \n", "5374 87.000000 106.0 235.0 9.000000 \n", "5388 85.000000 142.0 232.0 18.000000 \n", "5401 72.000000 153.0 253.0 4.000000 \n", "5414 62.000000 153.0 261.0 10.000000 \n", "\n", "[375 rows x 108 columns]" ] }, "execution_count": 54, "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": 55, "id": "d8b8b6da", "metadata": {}, "outputs": [], "source": [ "db_gk.to_excel('mid_outputs/database_entries_gk.xlsx')" ] }, { "cell_type": "code", "execution_count": 56, "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 }