{ "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": 21, "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": 22, "id": "8a6867a5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_5304\\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.021.0231.01890.038.027.06.08.0...232.0244.026.01.08.01.01261.0260.0317.045.1
BolognaBologna25.051.921.0231.01890.027.020.04.04.0...262.0254.036.03.04.01.01145.0239.0193.055.3
CremoneseCremonese30.044.221.0231.01890.015.07.02.04.0...232.0264.033.03.04.00.01168.0388.0296.056.7
EmpoliEmpoli27.046.821.0231.01890.019.011.00.00.0...270.0244.035.02.00.00.01104.0242.0211.053.4
FiorentinaFiorentina28.057.321.0231.01890.023.018.02.04.0...296.0252.054.01.04.00.01061.0274.0317.046.4
VeronaHellas Verona34.043.121.0231.01890.017.014.00.00.0...213.0302.024.01.00.02.01173.0385.0422.047.7
InterInter23.054.021.0231.01890.040.027.02.02.0...263.0237.019.02.02.01.0960.0221.0266.045.4
JuventusJuventus26.049.221.0231.01890.033.025.03.04.0...229.0232.027.00.04.00.01064.0247.0257.049.0
LazioLazio21.051.421.0231.01890.036.026.03.04.0...294.0206.044.01.04.01.01157.0207.0216.048.9
LecceLecce26.042.421.0231.01890.020.014.01.02.0...275.0279.045.03.02.01.01141.0396.0316.055.6
MilanMilan27.053.921.0231.01890.035.030.02.02.0...255.0251.025.04.02.02.01059.0249.0305.044.9
MonzaMonza29.055.921.0231.01890.026.016.04.04.0...303.0263.037.00.04.01.01075.0226.0241.048.4
NapoliNapoli24.061.421.0231.01890.051.040.05.06.0...291.0192.028.01.05.00.01049.0214.0259.045.2
RomaRoma26.048.921.0231.01890.028.019.03.05.0...292.0238.010.00.05.00.01095.0205.0245.045.6
SalernitanaSalernitana28.045.121.0231.01890.024.016.01.01.0...238.0242.052.08.01.01.01143.0268.0247.052.0
SampdoriaSampdoria31.047.921.0231.01890.010.08.00.00.0...328.0288.056.04.00.00.01126.0340.0339.050.1
SassuoloSassuolo29.048.521.0231.01890.024.018.04.05.0...275.0200.069.02.05.00.01088.0243.0195.055.5
SpeziaSpezia33.045.921.0231.01890.015.010.02.02.0...225.0279.050.01.02.02.01225.0337.0285.054.2
TorinoTorino25.053.021.0231.01890.022.017.01.01.0...229.0287.023.03.01.00.01095.0347.0319.052.1
UdineseUdinese25.050.021.0231.01890.027.023.00.00.0...274.0242.034.02.00.01.01063.0222.0264.045.7
\n", "

20 rows × 303 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 24.0 49.0 21.0 \n", "Bologna Bologna 25.0 51.9 21.0 \n", "Cremonese Cremonese 30.0 44.2 21.0 \n", "Empoli Empoli 27.0 46.8 21.0 \n", "Fiorentina Fiorentina 28.0 57.3 21.0 \n", "Verona Hellas Verona 34.0 43.1 21.0 \n", "Inter Inter 23.0 54.0 21.0 \n", "Juventus Juventus 26.0 49.2 21.0 \n", "Lazio Lazio 21.0 51.4 21.0 \n", "Lecce Lecce 26.0 42.4 21.0 \n", "Milan Milan 27.0 53.9 21.0 \n", "Monza Monza 29.0 55.9 21.0 \n", "Napoli Napoli 24.0 61.4 21.0 \n", "Roma Roma 26.0 48.9 21.0 \n", "Salernitana Salernitana 28.0 45.1 21.0 \n", "Sampdoria Sampdoria 31.0 47.9 21.0 \n", "Sassuolo Sassuolo 29.0 48.5 21.0 \n", "Spezia Spezia 33.0 45.9 21.0 \n", "Torino Torino 25.0 53.0 21.0 \n", "Udinese Udinese 25.0 50.0 21.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 231.0 1890.0 38.0 27.0 \n", "Bologna 231.0 1890.0 27.0 20.0 \n", "Cremonese 231.0 1890.0 15.0 7.0 \n", "Empoli 231.0 1890.0 19.0 11.0 \n", "Fiorentina 231.0 1890.0 23.0 18.0 \n", "Verona 231.0 1890.0 17.0 14.0 \n", "Inter 231.0 1890.0 40.0 27.0 \n", "Juventus 231.0 1890.0 33.0 25.0 \n", "Lazio 231.0 1890.0 36.0 26.0 \n", "Lecce 231.0 1890.0 20.0 14.0 \n", "Milan 231.0 1890.0 35.0 30.0 \n", "Monza 231.0 1890.0 26.0 16.0 \n", "Napoli 231.0 1890.0 51.0 40.0 \n", "Roma 231.0 1890.0 28.0 19.0 \n", "Salernitana 231.0 1890.0 24.0 16.0 \n", "Sampdoria 231.0 1890.0 10.0 8.0 \n", "Sassuolo 231.0 1890.0 24.0 18.0 \n", "Spezia 231.0 1890.0 15.0 10.0 \n", "Torino 231.0 1890.0 22.0 17.0 \n", "Udinese 231.0 1890.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 ... 232.0 \n", "Bologna 4.0 4.0 ... 262.0 \n", "Cremonese 2.0 4.0 ... 232.0 \n", "Empoli 0.0 0.0 ... 270.0 \n", "Fiorentina 2.0 4.0 ... 296.0 \n", "Verona 0.0 0.0 ... 213.0 \n", "Inter 2.0 2.0 ... 263.0 \n", "Juventus 3.0 4.0 ... 229.0 \n", "Lazio 3.0 4.0 ... 294.0 \n", "Lecce 1.0 2.0 ... 275.0 \n", "Milan 2.0 2.0 ... 255.0 \n", "Monza 4.0 4.0 ... 303.0 \n", "Napoli 5.0 6.0 ... 291.0 \n", "Roma 3.0 5.0 ... 292.0 \n", "Salernitana 1.0 1.0 ... 238.0 \n", "Sampdoria 0.0 0.0 ... 328.0 \n", "Sassuolo 4.0 5.0 ... 275.0 \n", "Spezia 2.0 2.0 ... 225.0 \n", "Torino 1.0 1.0 ... 229.0 \n", "Udinese 0.0 0.0 ... 274.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 244.0 26.0 1.0 \n", "Bologna 254.0 36.0 3.0 \n", "Cremonese 264.0 33.0 3.0 \n", "Empoli 244.0 35.0 2.0 \n", "Fiorentina 252.0 54.0 1.0 \n", "Verona 302.0 24.0 1.0 \n", "Inter 237.0 19.0 2.0 \n", "Juventus 232.0 27.0 0.0 \n", "Lazio 206.0 44.0 1.0 \n", "Lecce 279.0 45.0 3.0 \n", "Milan 251.0 25.0 4.0 \n", "Monza 263.0 37.0 0.0 \n", "Napoli 192.0 28.0 1.0 \n", "Roma 238.0 10.0 0.0 \n", "Salernitana 242.0 52.0 8.0 \n", "Sampdoria 288.0 56.0 4.0 \n", "Sassuolo 200.0 69.0 2.0 \n", "Spezia 279.0 50.0 1.0 \n", "Torino 287.0 23.0 3.0 \n", "Udinese 242.0 34.0 2.0 \n", "\n", " vs_team_pens_conceded vs_team_own_goals \\\n", "team_idx \n", "Atalanta 8.0 1.0 \n", "Bologna 4.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 4.0 0.0 \n", "Lazio 4.0 1.0 \n", "Lecce 2.0 1.0 \n", "Milan 2.0 2.0 \n", "Monza 4.0 1.0 \n", "Napoli 5.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 1261.0 260.0 \n", "Bologna 1145.0 239.0 \n", "Cremonese 1168.0 388.0 \n", "Empoli 1104.0 242.0 \n", "Fiorentina 1061.0 274.0 \n", "Verona 1173.0 385.0 \n", "Inter 960.0 221.0 \n", "Juventus 1064.0 247.0 \n", "Lazio 1157.0 207.0 \n", "Lecce 1141.0 396.0 \n", "Milan 1059.0 249.0 \n", "Monza 1075.0 226.0 \n", "Napoli 1049.0 214.0 \n", "Roma 1095.0 205.0 \n", "Salernitana 1143.0 268.0 \n", "Sampdoria 1126.0 340.0 \n", "Sassuolo 1088.0 243.0 \n", "Spezia 1225.0 337.0 \n", "Torino 1095.0 347.0 \n", "Udinese 1063.0 222.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 317.0 45.1 \n", "Bologna 193.0 55.3 \n", "Cremonese 296.0 56.7 \n", "Empoli 211.0 53.4 \n", "Fiorentina 317.0 46.4 \n", "Verona 422.0 47.7 \n", "Inter 266.0 45.4 \n", "Juventus 257.0 49.0 \n", "Lazio 216.0 48.9 \n", "Lecce 316.0 55.6 \n", "Milan 305.0 44.9 \n", "Monza 241.0 48.4 \n", "Napoli 259.0 45.2 \n", "Roma 245.0 45.6 \n", "Salernitana 247.0 52.0 \n", "Sampdoria 339.0 50.1 \n", "Sassuolo 195.0 55.5 \n", "Spezia 285.0 54.2 \n", "Torino 319.0 52.1 \n", "Udinese 264.0 45.7 \n", "\n", "[20 rows x 303 columns]" ] }, "execution_count": 22, "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": 23, "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": 24, "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
Meret0572PNapoliMeretNaN55125-32519970...19.527.1221.06.02.724.01.1417.26.2619050.478566
Provedel12814PLazioProvedelNaN56028-33019940...34.234.5279.07.02.539.01.8618.26.2619050.365769
Vicario24964PEmpoliVicarioNaN56926-12619960...47.242.4426.025.05.912.00.5710.96.4761900.392677
Szczesny3453PJuventusSzczesnyNaN56632-29819900...41.738.7178.04.02.212.00.8315.86.0333330.339935
Falcone42134PLecceFalconeNaN54627-30419950...76.151.7316.015.04.720.00.9512.56.3095240.361089
..................................................................
De Luca5385512ASampdoriaLucaNaN13424-20819981...0.00.00.00.00.00.00.000.05.9473970.490100
Voelkerling Persson5395837ALeccePerssonNaN50820-02620033...0.00.00.00.00.00.00.000.05.6942090.383547
Montevago5406113ASampdoriaMontevagoNaN33119-32920036...0.00.00.00.00.00.00.000.05.6239320.280948
Krollis5416143ASpeziaKrollisNaN25821-10520011...0.00.00.00.00.00.00.000.06.1242870.483769
Vivaldo5426160AUdineseVivaldoNaN-1000...0.00.00.00.00.00.00.000.06.2156790.378965
\n", "

543 rows × 160 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID \\\n", "name \n", "Meret 0 572 P Napoli Meret NaN 551 \n", "Provedel 1 2814 P Lazio Provedel NaN 560 \n", "Vicario 2 4964 P Empoli Vicario NaN 569 \n", "Szczesny 3 453 P Juventus Szczesny NaN 566 \n", "Falcone 4 2134 P Lecce Falcone NaN 546 \n", "... ... ... .. ... ... ... ... \n", "De Luca 538 5512 A Sampdoria Luca NaN 134 \n", "Voelkerling Persson 539 5837 A Lecce Persson NaN 508 \n", "Montevago 540 6113 A Sampdoria Montevago NaN 331 \n", "Krollis 541 6143 A Spezia Krollis NaN 258 \n", "Vivaldo 542 6160 A Udinese Vivaldo NaN -1 \n", "\n", " age birth_year games ... \\\n", "name ... \n", "Meret 25-325 1997 0 ... \n", "Provedel 28-330 1994 0 ... \n", "Vicario 26-126 1996 0 ... \n", "Szczesny 32-298 1990 0 ... \n", "Falcone 27-304 1995 0 ... \n", "... ... ... ... ... \n", "De Luca 24-208 1998 1 ... \n", "Voelkerling Persson 20-026 2003 3 ... \n", "Montevago 19-329 2003 6 ... \n", "Krollis 21-105 2001 1 ... \n", "Vivaldo 0 0 0 ... \n", "\n", " gk_pct_goal_kicks_launched gk_goal_kick_length_avg \\\n", "name \n", "Meret 19.5 27.1 \n", "Provedel 34.2 34.5 \n", "Vicario 47.2 42.4 \n", "Szczesny 41.7 38.7 \n", "Falcone 76.1 51.7 \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 221.0 6.0 2.7 \n", "Provedel 279.0 7.0 2.5 \n", "Vicario 426.0 25.0 5.9 \n", "Szczesny 178.0 4.0 2.2 \n", "Falcone 316.0 15.0 4.7 \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 39.0 \n", "Vicario 12.0 \n", "Szczesny 12.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.14 \n", "Provedel 1.86 \n", "Vicario 0.57 \n", "Szczesny 0.83 \n", "Falcone 0.95 \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.261905 0.478566 \n", "Provedel 18.2 6.261905 0.365769 \n", "Vicario 10.9 6.476190 0.392677 \n", "Szczesny 15.8 6.033333 0.339935 \n", "Falcone 12.5 6.309524 0.361089 \n", "... ... ... ... \n", "De Luca 0.0 5.947397 0.490100 \n", "Voelkerling Persson 0.0 5.694209 0.383547 \n", "Montevago 0.0 5.623932 0.280948 \n", "Krollis 0.0 6.124287 0.483769 \n", "Vivaldo 0.0 6.215679 0.378965 \n", "\n", "[543 rows x 160 columns]" ] }, "execution_count": 24, "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": 25, "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": 26, "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
Frattesi2742848CSassuoloFrattesiNaN19123-111199921...232.0244.026.01.08.01.01261.0260.0317.045.1
\n", "

1 rows × 766 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "Frattesi 274 2848 C Sassuolo Frattesi NaN 191 23-111 \n", "\n", " birth_year games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Frattesi 1999 21 ... 232.0 244.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 1261.0 260.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Frattesi 317.0 45.1 \n", "\n", "[1 rows x 766 columns]" ] }, "execution_count": 26, "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": 27, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Sassuolo'" ] }, "execution_count": 27, "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": 28, "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": 28, "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": 29, "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": 30, "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": 31, "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_pctaerials_won_pctteam_possession...miscontrolsdispossessedfoulsfouledaerials_wonaerials_lostcarriesprogressive_carriescarries_into_final_thirdcarries_into_penalty_area
FrattesiC2121172647.40.130.2878.657.148.5...0.018540.0162220.0156430.0214370.009270.0069520.2757820.0260720.0202780.008111
\n", "

1 rows × 112 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct \\\n", "Frattesi C 21 21 1726 47.4 \n", "\n", " goals_per_shot goals_per_shot_on_target passes_pct \\\n", "Frattesi 0.13 0.28 78.6 \n", "\n", " aerials_won_pct team_possession ... miscontrols dispossessed \\\n", "Frattesi 57.1 48.5 ... 0.01854 0.016222 \n", "\n", " fouls fouled aerials_won aerials_lost carries \\\n", "Frattesi 0.015643 0.021437 0.00927 0.006952 0.275782 \n", "\n", " progressive_carries carries_into_final_third \\\n", "Frattesi 0.026072 0.020278 \n", "\n", " carries_into_penalty_area \n", "Frattesi 0.008111 \n", "\n", "[1 rows x 112 columns]" ] }, "execution_count": 31, "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": 32, "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
.................................
598721DudaVeronaLazio16.0000.55.5
598821TamezeVeronaLazio16.0000.06.0
598921LasagnaVeronaLazio16.0000.06.0
599021GaichVeronaLazio16.0000.06.0
599121NgongeVeronaLazio17.0100.010.0
\n", "

5992 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", "5987 21 Duda Verona Lazio 1 6.0 0 0 \n", "5988 21 Tameze Verona Lazio 1 6.0 0 0 \n", "5989 21 Lasagna Verona Lazio 1 6.0 0 0 \n", "5990 21 Gaich Verona Lazio 1 6.0 0 0 \n", "5991 21 Ngonge Verona Lazio 1 7.0 1 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", "5987 0.5 5.5 \n", "5988 0.0 6.0 \n", "5989 0.0 6.0 \n", "5990 0.0 6.0 \n", "5991 0.0 10.0 \n", "\n", "[5992 rows x 10 columns]" ] }, "execution_count": 32, "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": 33, "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", "5800\n", "5900\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": 17, "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.0073640.0014730.0066270.0058910.0139910.0110460.3652430.0081000.0162000.000000
21DjimsitiAtalantaSampdoria06.0000.06.0...0.0018760.0075050.0056290.0056290.0225140.0150090.4878050.0037520.0037520.000000
31HateboerAtalantaSampdoria06.0000.55.5...0.0059930.0052430.0134830.0014980.0164790.0104870.2838950.0119850.0097380.000749
41OkoliAtalantaSampdoria05.5000.55.0...0.0130180.0035500.0153850.0082840.0473370.0272190.2698220.0023670.0047340.000000
..................................................................
598721DudaVeronaLazio16.0000.55.5...0.0162600.0243900.0162600.0243900.0162600.0081300.2520330.0081300.0081300.000000
598821TamezeVeronaLazio16.0000.06.0...0.0128040.0121640.0115240.0102430.0108830.0115240.2138280.0083230.0147250.001921
598921LasagnaVeronaLazio16.0000.06.0...0.0358420.0259860.0188170.0143370.0089610.0322580.1702510.0224010.0134410.009857
599021GaichVeronaLazio16.0000.06.0...0.1304350.0434780.0434780.0000000.0000000.1304350.2608700.0000000.0000000.043478
599121NgongeVeronaLazio17.0100.010.0...0.0117650.0117650.0000000.0235290.0588240.0588240.2470590.0352940.0117650.023529
\n", "

5992 rows × 122 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", "5987 21 Duda Verona Lazio 1 6.0 0 0 \n", "5988 21 Tameze Verona Lazio 1 6.0 0 0 \n", "5989 21 Lasagna Verona Lazio 1 6.0 0 0 \n", "5990 21 Gaich Verona Lazio 1 6.0 0 0 \n", "5991 21 Ngonge Verona Lazio 1 7.0 1 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.007364 0.001473 0.006627 \n", "2 0.0 6.0 ... 0.001876 0.007505 0.005629 \n", "3 0.5 5.5 ... 0.005993 0.005243 0.013483 \n", "4 0.5 5.0 ... 0.013018 0.003550 0.015385 \n", "... ... ... ... ... ... ... \n", "5987 0.5 5.5 ... 0.016260 0.024390 0.016260 \n", "5988 0.0 6.0 ... 0.012804 0.012164 0.011524 \n", "5989 0.0 6.0 ... 0.035842 0.025986 0.018817 \n", "5990 0.0 6.0 ... 0.130435 0.043478 0.043478 \n", "5991 0.0 10.0 ... 0.011765 0.011765 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.005891 0.013991 0.011046 0.365243 0.008100 \n", "2 0.005629 0.022514 0.015009 0.487805 0.003752 \n", "3 0.001498 0.016479 0.010487 0.283895 0.011985 \n", "4 0.008284 0.047337 0.027219 0.269822 0.002367 \n", "... ... ... ... ... ... \n", "5987 0.024390 0.016260 0.008130 0.252033 0.008130 \n", "5988 0.010243 0.010883 0.011524 0.213828 0.008323 \n", "5989 0.014337 0.008961 0.032258 0.170251 0.022401 \n", "5990 0.000000 0.000000 0.130435 0.260870 0.000000 \n", "5991 0.023529 0.058824 0.058824 0.247059 0.035294 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "0 0.000000 0.000000 \n", "1 0.016200 0.000000 \n", "2 0.003752 0.000000 \n", "3 0.009738 0.000749 \n", "4 0.004734 0.000000 \n", "... ... ... \n", "5987 0.008130 0.000000 \n", "5988 0.014725 0.001921 \n", "5989 0.013441 0.009857 \n", "5990 0.000000 0.043478 \n", "5991 0.011765 0.023529 \n", "\n", "[5992 rows x 122 columns]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "markdown", "id": "d237f87b", "metadata": {}, "source": [ "Remove undesired database entries." ] }, { "cell_type": "code", "execution_count": 18, "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": 19, "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.0073640.0014730.0066270.0058910.0139910.0110460.3652430.0081000.0162000.000000
21DjimsitiAtalantaSampdoria06.0000.06.0...0.0018760.0075050.0056290.0056290.0225140.0150090.4878050.0037520.0037520.000000
31HateboerAtalantaSampdoria06.0000.55.5...0.0059930.0052430.0134830.0014980.0164790.0104870.2838950.0119850.0097380.000749
41OkoliAtalantaSampdoria05.5000.55.0...0.0130180.0035500.0153850.0082840.0473370.0272190.2698220.0023670.0047340.000000
51ZorteaAtalantaSampdoria06.0000.55.5...0.0000000.0000000.0222220.0000000.0111110.0222220.5333330.0666670.0666670.000000
..................................................................
598721DudaVeronaLazio16.0000.55.5...0.0162600.0243900.0162600.0243900.0162600.0081300.2520330.0081300.0081300.000000
598821TamezeVeronaLazio16.0000.06.0...0.0128040.0121640.0115240.0102430.0108830.0115240.2138280.0083230.0147250.001921
598921LasagnaVeronaLazio16.0000.06.0...0.0358420.0259860.0188170.0143370.0089610.0322580.1702510.0224010.0134410.009857
599021GaichVeronaLazio16.0000.06.0...0.1304350.0434780.0434780.0000000.0000000.1304350.2608700.0000000.0000000.043478
599121NgongeVeronaLazio17.0100.010.0...0.0117650.0117650.0000000.0235290.0588240.0588240.2470590.0352940.0117650.023529
\n", "

5326 rows × 122 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", "5987 21 Duda Verona Lazio 1 6.0 0 0 \n", "5988 21 Tameze Verona Lazio 1 6.0 0 0 \n", "5989 21 Lasagna Verona Lazio 1 6.0 0 0 \n", "5990 21 Gaich Verona Lazio 1 6.0 0 0 \n", "5991 21 Ngonge Verona Lazio 1 7.0 1 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "1 0.0 10.0 ... 0.007364 0.001473 0.006627 \n", "2 0.0 6.0 ... 0.001876 0.007505 0.005629 \n", "3 0.5 5.5 ... 0.005993 0.005243 0.013483 \n", "4 0.5 5.0 ... 0.013018 0.003550 0.015385 \n", "5 0.5 5.5 ... 0.000000 0.000000 0.022222 \n", "... ... ... ... ... ... ... \n", "5987 0.5 5.5 ... 0.016260 0.024390 0.016260 \n", "5988 0.0 6.0 ... 0.012804 0.012164 0.011524 \n", "5989 0.0 6.0 ... 0.035842 0.025986 0.018817 \n", "5990 0.0 6.0 ... 0.130435 0.043478 0.043478 \n", "5991 0.0 10.0 ... 0.011765 0.011765 0.000000 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "1 0.005891 0.013991 0.011046 0.365243 0.008100 \n", "2 0.005629 0.022514 0.015009 0.487805 0.003752 \n", "3 0.001498 0.016479 0.010487 0.283895 0.011985 \n", "4 0.008284 0.047337 0.027219 0.269822 0.002367 \n", "5 0.000000 0.011111 0.022222 0.533333 0.066667 \n", "... ... ... ... ... ... \n", "5987 0.024390 0.016260 0.008130 0.252033 0.008130 \n", "5988 0.010243 0.010883 0.011524 0.213828 0.008323 \n", "5989 0.014337 0.008961 0.032258 0.170251 0.022401 \n", "5990 0.000000 0.000000 0.130435 0.260870 0.000000 \n", "5991 0.023529 0.058824 0.058824 0.247059 0.035294 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "1 0.016200 0.000000 \n", "2 0.003752 0.000000 \n", "3 0.009738 0.000749 \n", "4 0.004734 0.000000 \n", "5 0.066667 0.000000 \n", "... ... ... \n", "5987 0.008130 0.000000 \n", "5988 0.014725 0.001921 \n", "5989 0.013441 0.009857 \n", "5990 0.000000 0.043478 \n", "5991 0.011765 0.023529 \n", "\n", "[5326 rows x 122 columns]" ] }, "execution_count": 19, "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": 20, "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": 34, "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": 34, "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": 35, "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": 36, "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": 37, "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
Consigli191917101.4758.331.6-0.2541.631.034.3...23.30.35-4.7112.0269.0686.099.0172.0255.016.0
\n", "

1 rows × 92 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 19 19 1710 1.47 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 58.3 31.6 -0.25 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 41.6 31.0 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 34.3 ... 23.3 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.35 -4.7 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 112.0 269.0 686.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 99.0 172.0 255.0 16.0 \n", "\n", "[1 rows x 92 columns]" ] }, "execution_count": 37, "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": 38, "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", "5800\n", "5900\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": 39, "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...12.70.21-1.381.0185.0372.0107.098.0174.010.0
11ToloiAtalantaSampdoria07.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
21DjimsitiAtalantaSampdoria06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
31HateboerAtalantaSampdoria06.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
41OkoliAtalantaSampdoria05.5000.55.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
598721DudaVeronaLazio16.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
598821TamezeVeronaLazio16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
598921LasagnaVeronaLazio16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
599021GaichVeronaLazio16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
599121NgongeVeronaLazio17.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

5992 rows × 102 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", "5987 21 Duda Verona Lazio 1 6.0 0 0 \n", "5988 21 Tameze Verona Lazio 1 6.0 0 0 \n", "5989 21 Lasagna Verona Lazio 1 6.0 0 0 \n", "5990 21 Gaich Verona Lazio 1 6.0 0 0 \n", "5991 21 Ngonge Verona Lazio 1 7.0 1 0 \n", "\n", " cards_malus fantavote ... gk_psxg \\\n", "0 0.5 5.5 ... 12.7 \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", "5987 0.5 5.5 ... NaN \n", "5988 0.0 6.0 ... NaN \n", "5989 0.0 6.0 ... NaN \n", "5990 0.0 6.0 ... NaN \n", "5991 0.0 10.0 ... NaN \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.21 -1.3 \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "... ... ... \n", "5987 NaN NaN \n", "5988 NaN NaN \n", "5989 NaN NaN \n", "5990 NaN NaN \n", "5991 NaN NaN \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 81.0 185.0 372.0 \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "5987 NaN NaN NaN \n", "5988 NaN NaN NaN \n", "5989 NaN NaN NaN \n", "5990 NaN NaN NaN \n", "5991 NaN NaN NaN \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 107.0 98.0 174.0 10.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", "5987 NaN NaN NaN NaN \n", "5988 NaN NaN NaN NaN \n", "5989 NaN NaN NaN NaN \n", "5990 NaN NaN NaN NaN \n", "5991 NaN NaN NaN NaN \n", "\n", "[5992 rows x 102 columns]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db_gk" ] }, { "cell_type": "code", "execution_count": 40, "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": 41, "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...12.700.21-1.3081.0185.0372.0107.098.0174.010.0
151SkorupskiBolognaLazio06.5-200.04.5...30.800.281.8099.0240.0563.0117.0153.0299.018.0
441VicarioEmpoliSpezia05.5-100.04.5...26.400.270.40102.0310.0766.0113.0108.0426.025.0
571GolliniFiorentinaCremonese15.0-200.03.0...9.350.240.8524.068.0291.547.069.5122.53.5
711HandanovicInterLecce06.5-100.05.5...10.600.30-1.4027.052.0266.046.045.079.02.0
..................................................................
592921ConsigliSassuoloAtalanta16.0000.06.0...23.300.35-4.70112.0269.0686.099.0172.0255.016.0
594221DragowskiSpeziaNapoli15.0-300.02.0...28.100.27-3.9085.0268.0503.092.0109.0251.09.0
595321Milinkovic-Savic V.TorinoUdinese16.5000.06.5...21.900.23-0.10148.0524.0788.095.0155.0263.018.0
596621SilvestriUdineseTorino06.5-100.05.5...23.900.311.9090.0225.0450.076.0164.0275.05.0
598021Montipo'VeronaLazio16.0-100.05.0...27.600.25-4.40206.0413.0497.065.0168.0294.015.0
\n", "

415 rows × 102 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", "5929 21 Consigli Sassuolo Atalanta 1 6.0 0 \n", "5942 21 Dragowski Spezia Napoli 1 5.0 -3 \n", "5953 21 Milinkovic-Savic V. Torino Udinese 1 6.5 0 \n", "5966 21 Silvestri Udinese Torino 0 6.5 -1 \n", "5980 21 Montipo' Verona Lazio 1 6.0 -1 \n", "\n", " assists cards_malus fantavote ... gk_psxg \\\n", "0 0 0.5 5.5 ... 12.70 \n", "15 0 0.0 4.5 ... 30.80 \n", "44 0 0.0 4.5 ... 26.40 \n", "57 0 0.0 3.0 ... 9.35 \n", "71 0 0.0 5.5 ... 10.60 \n", "... ... ... ... ... ... \n", "5929 0 0.0 6.0 ... 23.30 \n", "5942 0 0.0 2.0 ... 28.10 \n", "5953 0 0.0 6.5 ... 21.90 \n", "5966 0 0.0 5.5 ... 23.90 \n", "5980 0 0.0 5.0 ... 27.60 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.21 -1.30 \n", "15 0.28 1.80 \n", "44 0.27 0.40 \n", "57 0.24 0.85 \n", "71 0.30 -1.40 \n", "... ... ... \n", "5929 0.35 -4.70 \n", "5942 0.27 -3.90 \n", "5953 0.23 -0.10 \n", "5966 0.31 1.90 \n", "5980 0.25 -4.40 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 81.0 185.0 372.0 \n", "15 99.0 240.0 563.0 \n", "44 102.0 310.0 766.0 \n", "57 24.0 68.0 291.5 \n", "71 27.0 52.0 266.0 \n", "... ... ... ... \n", "5929 112.0 269.0 686.0 \n", "5942 85.0 268.0 503.0 \n", "5953 148.0 524.0 788.0 \n", "5966 90.0 225.0 450.0 \n", "5980 206.0 413.0 497.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 107.0 98.0 174.0 10.0 \n", "15 117.0 153.0 299.0 18.0 \n", "44 113.0 108.0 426.0 25.0 \n", "57 47.0 69.5 122.5 3.5 \n", "71 46.0 45.0 79.0 2.0 \n", "... ... ... ... ... \n", "5929 99.0 172.0 255.0 16.0 \n", "5942 92.0 109.0 251.0 9.0 \n", "5953 95.0 155.0 263.0 18.0 \n", "5966 76.0 164.0 275.0 5.0 \n", "5980 65.0 168.0 294.0 15.0 \n", "\n", "[415 rows x 102 columns]" ] }, "execution_count": 41, "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": 42, "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 }