{ "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": 1, "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": 2, "id": "8a6867a5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_3244\\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.622.0242.01980.040.028.06.08.0...244.0256.026.01.08.01.01335.0273.0328.045.4
BolognaBologna25.052.422.0242.01980.027.020.04.04.0...280.0268.038.03.04.01.01204.0250.0210.054.3
CremoneseCremonese31.043.822.0242.01980.015.07.02.04.0...239.0271.036.03.04.00.01229.0409.0314.056.6
EmpoliEmpoli28.047.522.0242.01980.021.011.00.00.0...283.0253.036.02.00.00.01148.0263.0217.054.8
FiorentinaFiorentina28.057.222.0242.01980.023.018.02.04.0...307.0269.059.01.04.00.01130.0289.0328.046.8
VeronaHellas Verona34.042.922.0242.01980.018.015.00.00.0...234.0315.025.01.00.02.01231.0423.0445.048.7
InterInter23.054.522.0242.01980.040.027.02.02.0...276.0248.019.02.02.01.01007.0231.0288.044.5
JuventusJuventus26.049.022.0242.01980.034.026.03.04.0...246.0242.029.00.04.00.01134.0258.0272.048.7
LazioLazio21.051.822.0242.01980.036.026.03.04.0...308.0218.044.01.04.01.01233.0218.0229.048.8
LecceLecce26.042.422.0242.01980.020.014.01.02.0...283.0300.045.03.02.02.01200.0417.0332.055.7
MilanMilan27.053.522.0242.01980.036.031.02.02.0...275.0261.025.04.02.02.01125.0263.0325.044.7
MonzaMonza29.055.022.0242.01980.027.017.04.04.0...318.0281.037.00.04.01.01145.0242.0253.048.9
NapoliNapoli24.061.622.0242.01980.054.042.05.06.0...298.0199.028.01.05.00.01100.0232.0280.045.3
RomaRoma26.049.322.0242.01980.029.019.04.06.0...316.0246.012.00.06.00.01156.0221.0266.045.4
SalernitanaSalernitana28.046.022.0242.01980.024.016.01.01.0...252.0259.057.08.01.01.01213.0291.0285.050.5
SampdoriaSampdoria31.047.322.0242.01980.010.08.00.00.0...339.0300.059.04.00.00.01189.0362.0349.050.9
SassuoloSassuolo29.048.722.0242.01980.025.018.04.05.0...287.0206.072.02.05.01.01131.0256.0206.055.4
SpeziaSpezia33.045.522.0242.01980.017.010.03.03.0...235.0291.053.01.03.02.01275.0343.0306.052.9
TorinoTorino27.053.022.0242.01980.022.017.01.01.0...239.0306.024.03.01.00.01155.0367.0333.052.4
UdineseUdinese25.049.922.0242.01980.029.025.00.00.0...282.0252.034.02.00.01.01101.0233.0277.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 48.6 22.0 \n", "Bologna Bologna 25.0 52.4 22.0 \n", "Cremonese Cremonese 31.0 43.8 22.0 \n", "Empoli Empoli 28.0 47.5 22.0 \n", "Fiorentina Fiorentina 28.0 57.2 22.0 \n", "Verona Hellas Verona 34.0 42.9 22.0 \n", "Inter Inter 23.0 54.5 22.0 \n", "Juventus Juventus 26.0 49.0 22.0 \n", "Lazio Lazio 21.0 51.8 22.0 \n", "Lecce Lecce 26.0 42.4 22.0 \n", "Milan Milan 27.0 53.5 22.0 \n", "Monza Monza 29.0 55.0 22.0 \n", "Napoli Napoli 24.0 61.6 22.0 \n", "Roma Roma 26.0 49.3 22.0 \n", "Salernitana Salernitana 28.0 46.0 22.0 \n", "Sampdoria Sampdoria 31.0 47.3 22.0 \n", "Sassuolo Sassuolo 29.0 48.7 22.0 \n", "Spezia Spezia 33.0 45.5 22.0 \n", "Torino Torino 27.0 53.0 22.0 \n", "Udinese Udinese 25.0 49.9 22.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 242.0 1980.0 40.0 28.0 \n", "Bologna 242.0 1980.0 27.0 20.0 \n", "Cremonese 242.0 1980.0 15.0 7.0 \n", "Empoli 242.0 1980.0 21.0 11.0 \n", "Fiorentina 242.0 1980.0 23.0 18.0 \n", "Verona 242.0 1980.0 18.0 15.0 \n", "Inter 242.0 1980.0 40.0 27.0 \n", "Juventus 242.0 1980.0 34.0 26.0 \n", "Lazio 242.0 1980.0 36.0 26.0 \n", "Lecce 242.0 1980.0 20.0 14.0 \n", "Milan 242.0 1980.0 36.0 31.0 \n", "Monza 242.0 1980.0 27.0 17.0 \n", "Napoli 242.0 1980.0 54.0 42.0 \n", "Roma 242.0 1980.0 29.0 19.0 \n", "Salernitana 242.0 1980.0 24.0 16.0 \n", "Sampdoria 242.0 1980.0 10.0 8.0 \n", "Sassuolo 242.0 1980.0 25.0 18.0 \n", "Spezia 242.0 1980.0 17.0 10.0 \n", "Torino 242.0 1980.0 22.0 17.0 \n", "Udinese 242.0 1980.0 29.0 25.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls \\\n", "team_idx ... \n", "Atalanta 6.0 8.0 ... 244.0 \n", "Bologna 4.0 4.0 ... 280.0 \n", "Cremonese 2.0 4.0 ... 239.0 \n", "Empoli 0.0 0.0 ... 283.0 \n", "Fiorentina 2.0 4.0 ... 307.0 \n", "Verona 0.0 0.0 ... 234.0 \n", "Inter 2.0 2.0 ... 276.0 \n", "Juventus 3.0 4.0 ... 246.0 \n", "Lazio 3.0 4.0 ... 308.0 \n", "Lecce 1.0 2.0 ... 283.0 \n", "Milan 2.0 2.0 ... 275.0 \n", "Monza 4.0 4.0 ... 318.0 \n", "Napoli 5.0 6.0 ... 298.0 \n", "Roma 4.0 6.0 ... 316.0 \n", "Salernitana 1.0 1.0 ... 252.0 \n", "Sampdoria 0.0 0.0 ... 339.0 \n", "Sassuolo 4.0 5.0 ... 287.0 \n", "Spezia 3.0 3.0 ... 235.0 \n", "Torino 1.0 1.0 ... 239.0 \n", "Udinese 0.0 0.0 ... 282.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 256.0 26.0 1.0 \n", "Bologna 268.0 38.0 3.0 \n", "Cremonese 271.0 36.0 3.0 \n", "Empoli 253.0 36.0 2.0 \n", "Fiorentina 269.0 59.0 1.0 \n", "Verona 315.0 25.0 1.0 \n", "Inter 248.0 19.0 2.0 \n", "Juventus 242.0 29.0 0.0 \n", "Lazio 218.0 44.0 1.0 \n", "Lecce 300.0 45.0 3.0 \n", "Milan 261.0 25.0 4.0 \n", "Monza 281.0 37.0 0.0 \n", "Napoli 199.0 28.0 1.0 \n", "Roma 246.0 12.0 0.0 \n", "Salernitana 259.0 57.0 8.0 \n", "Sampdoria 300.0 59.0 4.0 \n", "Sassuolo 206.0 72.0 2.0 \n", "Spezia 291.0 53.0 1.0 \n", "Torino 306.0 24.0 3.0 \n", "Udinese 252.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 2.0 \n", "Milan 2.0 2.0 \n", "Monza 4.0 1.0 \n", "Napoli 5.0 0.0 \n", "Roma 6.0 0.0 \n", "Salernitana 1.0 1.0 \n", "Sampdoria 0.0 0.0 \n", "Sassuolo 5.0 1.0 \n", "Spezia 3.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 1335.0 273.0 \n", "Bologna 1204.0 250.0 \n", "Cremonese 1229.0 409.0 \n", "Empoli 1148.0 263.0 \n", "Fiorentina 1130.0 289.0 \n", "Verona 1231.0 423.0 \n", "Inter 1007.0 231.0 \n", "Juventus 1134.0 258.0 \n", "Lazio 1233.0 218.0 \n", "Lecce 1200.0 417.0 \n", "Milan 1125.0 263.0 \n", "Monza 1145.0 242.0 \n", "Napoli 1100.0 232.0 \n", "Roma 1156.0 221.0 \n", "Salernitana 1213.0 291.0 \n", "Sampdoria 1189.0 362.0 \n", "Sassuolo 1131.0 256.0 \n", "Spezia 1275.0 343.0 \n", "Torino 1155.0 367.0 \n", "Udinese 1101.0 233.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 328.0 45.4 \n", "Bologna 210.0 54.3 \n", "Cremonese 314.0 56.6 \n", "Empoli 217.0 54.8 \n", "Fiorentina 328.0 46.8 \n", "Verona 445.0 48.7 \n", "Inter 288.0 44.5 \n", "Juventus 272.0 48.7 \n", "Lazio 229.0 48.8 \n", "Lecce 332.0 55.7 \n", "Milan 325.0 44.7 \n", "Monza 253.0 48.9 \n", "Napoli 280.0 45.3 \n", "Roma 266.0 45.4 \n", "Salernitana 285.0 50.5 \n", "Sampdoria 349.0 50.9 \n", "Sassuolo 206.0 55.4 \n", "Spezia 306.0 52.9 \n", "Torino 333.0 52.4 \n", "Udinese 277.0 45.7 \n", "\n", "[20 rows x 303 columns]" ] }, "execution_count": 2, "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": 3, "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": 4, "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
Meret0572PNapoliMeretNaN55525-32919970...18.726.6232.06.02.624.01.0917.26.2500000.470734
Provedel12814PLazioProvedelNaN56428-33419940...35.035.0290.08.02.839.01.7818.16.2727270.360784
Vicario24964PEmpoliVicarioNaN57326-13019960...44.741.5431.025.05.812.00.5510.96.4545450.396264
Szczesny3453PJuventusSzczesnyNaN57032-30219900...47.641.8198.05.02.512.00.7815.46.0312500.329239
Falcone42134PLecceFalconeNaN55027-30819950...76.351.9327.015.04.622.01.0012.86.3636360.431220
..................................................................
De Luca5385512ASampdoriaLucaNaN13524-21219981...0.00.00.00.00.00.00.000.06.1528920.608256
Voelkerling Persson5395837ALeccePerssonNaN51220-03020034...0.00.00.00.00.00.00.000.06.1175740.756644
Montevago5406113ASampdoriaMontevagoNaN33419-33320036...0.00.00.00.00.00.00.000.05.8038860.322430
Krollis5416143ASpeziaKrollisNaN26121-10920011...0.00.00.00.00.00.00.000.05.6899790.321766
Vivaldo5426160AUdineseVivaldoNaN-1000...0.00.00.00.00.00.00.000.05.8357420.342133
\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 555 \n", "Provedel 1 2814 P Lazio Provedel NaN 564 \n", "Vicario 2 4964 P Empoli Vicario NaN 573 \n", "Szczesny 3 453 P Juventus Szczesny NaN 570 \n", "Falcone 4 2134 P Lecce Falcone NaN 550 \n", "... ... ... .. ... ... ... ... \n", "De Luca 538 5512 A Sampdoria Luca NaN 135 \n", "Voelkerling Persson 539 5837 A Lecce Persson NaN 512 \n", "Montevago 540 6113 A Sampdoria Montevago NaN 334 \n", "Krollis 541 6143 A Spezia Krollis NaN 261 \n", "Vivaldo 542 6160 A Udinese Vivaldo NaN -1 \n", "\n", " age birth_year games ... \\\n", "name ... \n", "Meret 25-329 1997 0 ... \n", "Provedel 28-334 1994 0 ... \n", "Vicario 26-130 1996 0 ... \n", "Szczesny 32-302 1990 0 ... \n", "Falcone 27-308 1995 0 ... \n", "... ... ... ... ... \n", "De Luca 24-212 1998 1 ... \n", "Voelkerling Persson 20-030 2003 4 ... \n", "Montevago 19-333 2003 6 ... \n", "Krollis 21-109 2001 1 ... \n", "Vivaldo 0 0 0 ... \n", "\n", " gk_pct_goal_kicks_launched gk_goal_kick_length_avg \\\n", "name \n", "Meret 18.7 26.6 \n", "Provedel 35.0 35.0 \n", "Vicario 44.7 41.5 \n", "Szczesny 47.6 41.8 \n", "Falcone 76.3 51.9 \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 232.0 6.0 2.6 \n", "Provedel 290.0 8.0 2.8 \n", "Vicario 431.0 25.0 5.8 \n", "Szczesny 198.0 5.0 2.5 \n", "Falcone 327.0 15.0 4.6 \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 22.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.09 \n", "Provedel 1.78 \n", "Vicario 0.55 \n", "Szczesny 0.78 \n", "Falcone 1.00 \n", "... ... \n", "De Luca 0.00 \n", "Voelkerling Persson 0.00 \n", "Montevago 0.00 \n", "Krollis 0.00 \n", "Vivaldo 0.00 \n", "\n", " gk_avg_distance_def_actions vote_avg vote_std \n", "name \n", "Meret 17.2 6.250000 0.470734 \n", "Provedel 18.1 6.272727 0.360784 \n", "Vicario 10.9 6.454545 0.396264 \n", "Szczesny 15.4 6.031250 0.329239 \n", "Falcone 12.8 6.363636 0.431220 \n", "... ... ... ... \n", "De Luca 0.0 6.152892 0.608256 \n", "Voelkerling Persson 0.0 6.117574 0.756644 \n", "Montevago 0.0 5.803886 0.322430 \n", "Krollis 0.0 5.689979 0.321766 \n", "Vivaldo 0.0 5.835742 0.342133 \n", "\n", "[543 rows x 160 columns]" ] }, "execution_count": 4, "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": 5, "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": 6, "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
Frattesi2742848CSassuoloFrattesiNaN19223-115199922...244.0256.026.01.08.01.01335.0273.0328.045.4
\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 192 23-115 \n", "\n", " birth_year games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Frattesi 1999 22 ... 244.0 256.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 1335.0 273.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Frattesi 328.0 45.4 \n", "\n", "[1 rows x 766 columns]" ] }, "execution_count": 6, "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": 7, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Sassuolo'" ] }, "execution_count": 7, "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": 8, "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": 8, "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": 9, "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": 10, "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": 11, "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
FrattesiC2222181645.00.130.2878.558.648.7...0.0187220.0154190.0154190.0209250.0093610.0066080.2780840.0258810.0203740.007709
\n", "

1 rows × 112 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct \\\n", "Frattesi C 22 22 1816 45.0 \n", "\n", " goals_per_shot goals_per_shot_on_target passes_pct \\\n", "Frattesi 0.13 0.28 78.5 \n", "\n", " aerials_won_pct team_possession ... miscontrols dispossessed \\\n", "Frattesi 58.6 48.7 ... 0.018722 0.015419 \n", "\n", " fouls fouled aerials_won aerials_lost carries \\\n", "Frattesi 0.015419 0.020925 0.009361 0.006608 0.278084 \n", "\n", " progressive_carries carries_into_final_third \\\n", "Frattesi 0.025881 0.020374 \n", "\n", " carries_into_penalty_area \n", "Frattesi 0.007709 \n", "\n", "[1 rows x 112 columns]" ] }, "execution_count": 11, "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": 12, "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
.................................
626322TamezeVeronaSalernitana16.0000.06.0
626422AbildgaardVeronaSalernitana16.0000.06.0
626522LasagnaVeronaSalernitana16.0000.06.0
626622GaichVeronaSalernitana16.5000.06.5
626722NgongeVeronaSalernitana17.0100.010.0
\n", "

6268 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", "6263 22 Tameze Verona Salernitana 1 6.0 0 0 \n", "6264 22 Abildgaard Verona Salernitana 1 6.0 0 0 \n", "6265 22 Lasagna Verona Salernitana 1 6.0 0 0 \n", "6266 22 Gaich Verona Salernitana 1 6.5 0 0 \n", "6267 22 Ngonge Verona Salernitana 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", "6263 0.0 6.0 \n", "6264 0.0 6.0 \n", "6265 0.0 6.0 \n", "6266 0.0 6.5 \n", "6267 0.0 10.0 \n", "\n", "[6268 rows x 10 columns]" ] }, "execution_count": 12, "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": 13, "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", "6000\n", "6100\n", "6200\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": 14, "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.0069060.0013810.0075970.0069060.0138120.0103590.3563540.0082870.0158840.000000
21DjimsitiAtalantaSampdoria06.0000.06.0...0.0032100.0064210.0048150.0048150.0224720.0144460.4622790.0048150.0048150.000000
31HateboerAtalantaSampdoria06.0000.55.5...0.0057270.0050110.0136010.0021470.0171800.0100210.2827490.0114530.0093060.000716
41OkoliAtalantaSampdoria05.5000.55.0...0.0130180.0035500.0153850.0082840.0473370.0272190.2698220.0023670.0047340.000000
..................................................................
626322TamezeVeronaSalernitana16.0000.06.0...0.0133170.0121070.0115010.0096850.0115010.0108960.2136800.0078690.0139230.001816
626422AbildgaardVeronaSalernitana16.0000.06.0...0.0000000.0000000.0270270.0270270.0810810.0270270.1081080.0000000.0000000.000000
626522LasagnaVeronaSalernitana16.0000.06.0...0.0353980.0256640.0185840.0150440.0088500.0371680.1707960.0221240.0132740.009735
626622GaichVeronaSalernitana16.5000.06.5...0.0574710.0459770.0229890.0344830.0344830.1264370.2988510.0114940.0000000.011494
626722NgongeVeronaSalernitana17.0100.010.0...0.0559010.0124220.0062110.0310560.0310560.0869570.2981370.0372670.0124220.012422
\n", "

6268 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", "6263 22 Tameze Verona Salernitana 1 6.0 0 0 \n", "6264 22 Abildgaard Verona Salernitana 1 6.0 0 0 \n", "6265 22 Lasagna Verona Salernitana 1 6.0 0 0 \n", "6266 22 Gaich Verona Salernitana 1 6.5 0 0 \n", "6267 22 Ngonge Verona Salernitana 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.006906 0.001381 0.007597 \n", "2 0.0 6.0 ... 0.003210 0.006421 0.004815 \n", "3 0.5 5.5 ... 0.005727 0.005011 0.013601 \n", "4 0.5 5.0 ... 0.013018 0.003550 0.015385 \n", "... ... ... ... ... ... ... \n", "6263 0.0 6.0 ... 0.013317 0.012107 0.011501 \n", "6264 0.0 6.0 ... 0.000000 0.000000 0.027027 \n", "6265 0.0 6.0 ... 0.035398 0.025664 0.018584 \n", "6266 0.0 6.5 ... 0.057471 0.045977 0.022989 \n", "6267 0.0 10.0 ... 0.055901 0.012422 0.006211 \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.006906 0.013812 0.010359 0.356354 0.008287 \n", "2 0.004815 0.022472 0.014446 0.462279 0.004815 \n", "3 0.002147 0.017180 0.010021 0.282749 0.011453 \n", "4 0.008284 0.047337 0.027219 0.269822 0.002367 \n", "... ... ... ... ... ... \n", "6263 0.009685 0.011501 0.010896 0.213680 0.007869 \n", "6264 0.027027 0.081081 0.027027 0.108108 0.000000 \n", "6265 0.015044 0.008850 0.037168 0.170796 0.022124 \n", "6266 0.034483 0.034483 0.126437 0.298851 0.011494 \n", "6267 0.031056 0.031056 0.086957 0.298137 0.037267 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "0 0.000000 0.000000 \n", "1 0.015884 0.000000 \n", "2 0.004815 0.000000 \n", "3 0.009306 0.000716 \n", "4 0.004734 0.000000 \n", "... ... ... \n", "6263 0.013923 0.001816 \n", "6264 0.000000 0.000000 \n", "6265 0.013274 0.009735 \n", "6266 0.000000 0.011494 \n", "6267 0.012422 0.012422 \n", "\n", "[6268 rows x 122 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "markdown", "id": "d237f87b", "metadata": {}, "source": [ "Remove undesired database entries." ] }, { "cell_type": "code", "execution_count": 15, "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": 16, "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.0069060.0013810.0075970.0069060.0138120.0103590.3563540.0082870.0158840.000000
21DjimsitiAtalantaSampdoria06.0000.06.0...0.0032100.0064210.0048150.0048150.0224720.0144460.4622790.0048150.0048150.000000
31HateboerAtalantaSampdoria06.0000.55.5...0.0057270.0050110.0136010.0021470.0171800.0100210.2827490.0114530.0093060.000716
41OkoliAtalantaSampdoria05.5000.55.0...0.0130180.0035500.0153850.0082840.0473370.0272190.2698220.0023670.0047340.000000
51ZorteaAtalantaSampdoria06.0000.55.5...0.0111110.0055560.0166670.0222220.0166670.0277780.5611110.0722220.0555560.000000
..................................................................
626322TamezeVeronaSalernitana16.0000.06.0...0.0133170.0121070.0115010.0096850.0115010.0108960.2136800.0078690.0139230.001816
626422AbildgaardVeronaSalernitana16.0000.06.0...0.0000000.0000000.0270270.0270270.0810810.0270270.1081080.0000000.0000000.000000
626522LasagnaVeronaSalernitana16.0000.06.0...0.0353980.0256640.0185840.0150440.0088500.0371680.1707960.0221240.0132740.009735
626622GaichVeronaSalernitana16.5000.06.5...0.0574710.0459770.0229890.0344830.0344830.1264370.2988510.0114940.0000000.011494
626722NgongeVeronaSalernitana17.0100.010.0...0.0559010.0124220.0062110.0310560.0310560.0869570.2981370.0372670.0124220.012422
\n", "

5581 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", "6263 22 Tameze Verona Salernitana 1 6.0 0 0 \n", "6264 22 Abildgaard Verona Salernitana 1 6.0 0 0 \n", "6265 22 Lasagna Verona Salernitana 1 6.0 0 0 \n", "6266 22 Gaich Verona Salernitana 1 6.5 0 0 \n", "6267 22 Ngonge Verona Salernitana 1 7.0 1 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "1 0.0 10.0 ... 0.006906 0.001381 0.007597 \n", "2 0.0 6.0 ... 0.003210 0.006421 0.004815 \n", "3 0.5 5.5 ... 0.005727 0.005011 0.013601 \n", "4 0.5 5.0 ... 0.013018 0.003550 0.015385 \n", "5 0.5 5.5 ... 0.011111 0.005556 0.016667 \n", "... ... ... ... ... ... ... \n", "6263 0.0 6.0 ... 0.013317 0.012107 0.011501 \n", "6264 0.0 6.0 ... 0.000000 0.000000 0.027027 \n", "6265 0.0 6.0 ... 0.035398 0.025664 0.018584 \n", "6266 0.0 6.5 ... 0.057471 0.045977 0.022989 \n", "6267 0.0 10.0 ... 0.055901 0.012422 0.006211 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "1 0.006906 0.013812 0.010359 0.356354 0.008287 \n", "2 0.004815 0.022472 0.014446 0.462279 0.004815 \n", "3 0.002147 0.017180 0.010021 0.282749 0.011453 \n", "4 0.008284 0.047337 0.027219 0.269822 0.002367 \n", "5 0.022222 0.016667 0.027778 0.561111 0.072222 \n", "... ... ... ... ... ... \n", "6263 0.009685 0.011501 0.010896 0.213680 0.007869 \n", "6264 0.027027 0.081081 0.027027 0.108108 0.000000 \n", "6265 0.015044 0.008850 0.037168 0.170796 0.022124 \n", "6266 0.034483 0.034483 0.126437 0.298851 0.011494 \n", "6267 0.031056 0.031056 0.086957 0.298137 0.037267 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "1 0.015884 0.000000 \n", "2 0.004815 0.000000 \n", "3 0.009306 0.000716 \n", "4 0.004734 0.000000 \n", "5 0.055556 0.000000 \n", "... ... ... \n", "6263 0.013923 0.001816 \n", "6264 0.000000 0.000000 \n", "6265 0.013274 0.009735 \n", "6266 0.000000 0.011494 \n", "6267 0.012422 0.012422 \n", "\n", "[5581 rows x 122 columns]" ] }, "execution_count": 16, "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": 17, "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": 18, "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 - aerials_won_pct\n", "19 - team_possession\n", "20 - team_goals_assists_per90\n", "21 - team_goals_pens_per90\n", "22 - team_goals_assists_pens_per90\n", "23 - team_xg_per90\n", "24 - team_gk_goals_against_per90\n", "25 - team_gk_save_pct\n", "26 - team_gk_clean_sheets_pct\n", "27 - team_passes_pct\n", "28 - team_passes_pct_medium\n", "29 - team_passes_pct_long\n", "30 - team_sca_per90\n", "31 - team_gca_per90\n", "32 - team_aerials_won_pct\n", "33 - vs_team_possession\n", "34 - vs_team_goals_per90\n", "35 - vs_team_assists_per90\n", "36 - vs_team_xg_per90\n", "37 - vs_team_gk_save_pct\n", "38 - vs_team_gk_clean_sheets_pct\n", "39 - vs_team_gk_pct_passes_launched\n", "40 - vs_team_gk_crosses_stopped_pct\n", "41 - vs_team_shots_on_target_per90\n", "42 - vs_team_passes_pct\n", "43 - vs_team_passes_pct_short\n", "44 - vs_team_passes_pct_medium\n", "45 - vs_team_passes_pct_long\n", "46 - vs_team_sca_per90\n", "47 - vs_team_gca_per90\n", "48 - vs_team_aerials_won_pct\n", "49 - opp_team_possession\n", "50 - opp_team_goals_assists_per90\n", "51 - opp_team_goals_pens_per90\n", "52 - opp_team_goals_assists_pens_per90\n", "53 - opp_team_xg_per90\n", "54 - opp_team_gk_goals_against_per90\n", "55 - opp_team_gk_save_pct\n", "56 - opp_team_gk_clean_sheets_pct\n", "57 - opp_team_passes_pct\n", "58 - opp_team_passes_pct_medium\n", "59 - opp_team_passes_pct_long\n", "60 - opp_team_sca_per90\n", "61 - opp_team_gca_per90\n", "62 - opp_team_aerials_won_pct\n", "63 - opp_vs_team_possession\n", "64 - opp_vs_team_goals_per90\n", "65 - opp_vs_team_assists_per90\n", "66 - opp_vs_team_xg_per90\n", "67 - opp_vs_team_gk_save_pct\n", "68 - opp_vs_team_gk_clean_sheets_pct\n", "69 - opp_vs_team_gk_pct_passes_launched\n", "70 - opp_vs_team_gk_crosses_stopped_pct\n", "71 - opp_vs_team_shots_on_target_per90\n", "72 - opp_vs_team_passes_pct\n", "73 - opp_vs_team_passes_pct_short\n", "74 - opp_vs_team_passes_pct_medium\n", "75 - opp_vs_team_passes_pct_long\n", "76 - opp_vs_team_sca_per90\n", "77 - opp_vs_team_gca_per90\n", "78 - opp_vs_team_aerials_won_pct\n", "79 - vote_avg\n", "80 - vote_std\n", "81 - goals\n", "82 - assists\n", "83 - cards_yellow\n", "84 - cards_red\n", "85 - xg\n", "86 - npxg\n", "87 - shots_on_target\n", "88 - passes_completed\n", "89 - passes_into_final_third\n", "90 - passes_into_penalty_area\n", "91 - progressive_passes\n", "92 - passes_live\n", "93 - passes_dead\n", "94 - through_balls\n", "95 - passes_switches\n", "96 - crosses\n", "97 - corner_kicks\n", "98 - blocks\n", "99 - blocked_shots\n", "100 - blocked_passes\n", "101 - interceptions\n", "102 - clearances\n", "103 - errors\n", "104 - touches\n", "105 - touches_def_pen_area\n", "106 - touches_def_3rd\n", "107 - touches_mid_3rd\n", "108 - touches_att_3rd\n", "109 - touches_att_pen_area\n", "110 - touches_live_ball\n", "111 - passes_received\n", "112 - miscontrols\n", "113 - dispossessed\n", "114 - fouls\n", "115 - fouled\n", "116 - aerials_won\n", "117 - aerials_lost\n", "118 - carries\n", "119 - progressive_carries\n", "120 - carries_into_final_third\n", "121 - carries_into_penalty_area\n" ] } ], "source": [ "for i in range(db.columns.shape[0]):\n", " print(str(i) + \" - \" + str(db.columns[i]))" ] }, { "cell_type": "code", "execution_count": 19, "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": 19, "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": 20, "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": 21, "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": 22, "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
Consigli202018001.559.730.0-0.2840.830.534.1...24.40.33-5.6113.0277.0711.0108.0179.0276.017.0
\n", "

1 rows × 92 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 20 20 1800 1.5 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 59.7 30.0 -0.28 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 40.8 30.5 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 34.1 ... 24.4 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.33 -5.6 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 113.0 277.0 711.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 108.0 179.0 276.0 17.0 \n", "\n", "[1 rows x 92 columns]" ] }, "execution_count": 22, "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": 23, "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", "6000\n", "6100\n", "6200\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": 24, "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...13.00.2-1.088.0201.0397.0112.0101.0186.010.0
11ToloiAtalantaSampdoria07.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
21DjimsitiAtalantaSampdoria06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
31HateboerAtalantaSampdoria06.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
41OkoliAtalantaSampdoria05.5000.55.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
626322TamezeVeronaSalernitana16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
626422AbildgaardVeronaSalernitana16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
626522LasagnaVeronaSalernitana16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
626622GaichVeronaSalernitana16.5000.06.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
626722NgongeVeronaSalernitana17.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

6268 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", "6263 22 Tameze Verona Salernitana 1 6.0 0 0 \n", "6264 22 Abildgaard Verona Salernitana 1 6.0 0 0 \n", "6265 22 Lasagna Verona Salernitana 1 6.0 0 0 \n", "6266 22 Gaich Verona Salernitana 1 6.5 0 0 \n", "6267 22 Ngonge Verona Salernitana 1 7.0 1 0 \n", "\n", " cards_malus fantavote ... gk_psxg \\\n", "0 0.5 5.5 ... 13.0 \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", "6263 0.0 6.0 ... NaN \n", "6264 0.0 6.0 ... NaN \n", "6265 0.0 6.0 ... NaN \n", "6266 0.0 6.5 ... NaN \n", "6267 0.0 10.0 ... NaN \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.2 -1.0 \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "... ... ... \n", "6263 NaN NaN \n", "6264 NaN NaN \n", "6265 NaN NaN \n", "6266 NaN NaN \n", "6267 NaN NaN \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 88.0 201.0 397.0 \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "6263 NaN NaN NaN \n", "6264 NaN NaN NaN \n", "6265 NaN NaN NaN \n", "6266 NaN NaN NaN \n", "6267 NaN NaN NaN \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 112.0 101.0 186.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", "6263 NaN NaN NaN NaN \n", "6264 NaN NaN NaN NaN \n", "6265 NaN NaN NaN NaN \n", "6266 NaN NaN NaN NaN \n", "6267 NaN NaN NaN NaN \n", "\n", "[6268 rows x 102 columns]" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db_gk" ] }, { "cell_type": "code", "execution_count": 25, "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": 26, "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...13.000.20-1.0088.0201.0397.0112.0101.0186.010.0
151SkorupskiBolognaLazio06.5-200.04.5...32.500.292.50101.0242.0576.0117.0159.0304.018.0
441VicarioEmpoliSpezia05.5-100.04.5...27.800.26-0.20102.0313.0806.0117.0114.0431.025.0
571GolliniFiorentinaCremonese15.0-200.03.0...9.450.240.9524.068.0299.548.572.5128.03.5
711HandanovicInterLecce06.5-100.05.5...10.600.30-1.4027.052.0266.046.045.079.02.0
..................................................................
620022ConsigliSassuoloUdinese07.0-200.05.0...24.400.33-5.60113.0277.0711.0108.0179.0276.017.0
621422DragowskiSpeziaEmpoli06.5-200.04.5...29.500.27-4.5093.0285.0528.097.0122.0270.09.0
622722Milinkovic-Savic V.TorinoMilan06.5-100.05.5...23.100.240.10150.0540.0817.097.0160.0271.019.0
624122SilvestriUdineseSassuolo16.0-200.04.0...24.000.311.0091.0227.0470.080.0175.0293.05.0
625422Montipo'VeronaSalernitana16.5000.06.5...28.700.26-3.30208.0433.0513.067.0175.0305.015.0
\n", "

435 rows × 102 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", "6200 22 Consigli Sassuolo Udinese 0 7.0 \n", "6214 22 Dragowski Spezia Empoli 0 6.5 \n", "6227 22 Milinkovic-Savic V. Torino Milan 0 6.5 \n", "6241 22 Silvestri Udinese Sassuolo 1 6.0 \n", "6254 22 Montipo' Verona Salernitana 1 6.5 \n", "\n", " goals assists cards_malus fantavote ... gk_psxg \\\n", "0 0 0 0.5 5.5 ... 13.00 \n", "15 -2 0 0.0 4.5 ... 32.50 \n", "44 -1 0 0.0 4.5 ... 27.80 \n", "57 -2 0 0.0 3.0 ... 9.45 \n", "71 -1 0 0.0 5.5 ... 10.60 \n", "... ... ... ... ... ... ... \n", "6200 -2 0 0.0 5.0 ... 24.40 \n", "6214 -2 0 0.0 4.5 ... 29.50 \n", "6227 -1 0 0.0 5.5 ... 23.10 \n", "6241 -2 0 0.0 4.0 ... 24.00 \n", "6254 0 0 0.0 6.5 ... 28.70 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.20 -1.00 \n", "15 0.29 2.50 \n", "44 0.26 -0.20 \n", "57 0.24 0.95 \n", "71 0.30 -1.40 \n", "... ... ... \n", "6200 0.33 -5.60 \n", "6214 0.27 -4.50 \n", "6227 0.24 0.10 \n", "6241 0.31 1.00 \n", "6254 0.26 -3.30 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 88.0 201.0 397.0 \n", "15 101.0 242.0 576.0 \n", "44 102.0 313.0 806.0 \n", "57 24.0 68.0 299.5 \n", "71 27.0 52.0 266.0 \n", "... ... ... ... \n", "6200 113.0 277.0 711.0 \n", "6214 93.0 285.0 528.0 \n", "6227 150.0 540.0 817.0 \n", "6241 91.0 227.0 470.0 \n", "6254 208.0 433.0 513.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 112.0 101.0 186.0 10.0 \n", "15 117.0 159.0 304.0 18.0 \n", "44 117.0 114.0 431.0 25.0 \n", "57 48.5 72.5 128.0 3.5 \n", "71 46.0 45.0 79.0 2.0 \n", "... ... ... ... ... \n", "6200 108.0 179.0 276.0 17.0 \n", "6214 97.0 122.0 270.0 9.0 \n", "6227 97.0 160.0 271.0 19.0 \n", "6241 80.0 175.0 293.0 5.0 \n", "6254 67.0 175.0 305.0 15.0 \n", "\n", "[435 rows x 102 columns]" ] }, "execution_count": 26, "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": 27, "id": "d8b8b6da", "metadata": {}, "outputs": [], "source": [ "db_gk.to_excel('mid_outputs/database_entries_gk.xlsx')" ] }, { "cell_type": "code", "execution_count": 28, "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_aerials_won_pct\n", "39 - vs_team_possession\n", "40 - vs_team_goals_per90\n", "41 - vs_team_assists_per90\n", "42 - vs_team_xg_per90\n", "43 - vs_team_gk_save_pct\n", "44 - vs_team_gk_clean_sheets_pct\n", "45 - vs_team_gk_pct_passes_launched\n", "46 - vs_team_gk_crosses_stopped_pct\n", "47 - vs_team_shots_on_target_per90\n", "48 - vs_team_passes_pct\n", "49 - vs_team_passes_pct_short\n", "50 - vs_team_passes_pct_medium\n", "51 - vs_team_passes_pct_long\n", "52 - vs_team_sca_per90\n", "53 - vs_team_gca_per90\n", "54 - vs_team_aerials_won_pct\n", "55 - opp_team_possession\n", "56 - opp_team_goals_assists_per90\n", "57 - opp_team_goals_pens_per90\n", "58 - opp_team_goals_assists_pens_per90\n", "59 - opp_team_xg_per90\n", "60 - opp_team_gk_goals_against_per90\n", "61 - opp_team_gk_save_pct\n", "62 - opp_team_gk_clean_sheets_pct\n", "63 - opp_team_passes_pct\n", "64 - opp_team_passes_pct_medium\n", "65 - opp_team_passes_pct_long\n", "66 - opp_team_sca_per90\n", "67 - opp_team_gca_per90\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_aerials_won_pct\n", "85 - vote_avg\n", "86 - vote_std\n", "87 - gk_shots_on_target_against\n", "88 - gk_saves\n", "89 - gk_free_kick_goals_against\n", "90 - gk_corner_kick_goals_against\n", "91 - gk_own_goals_against\n", "92 - gk_psxg\n", "93 - gk_psnpxg_per_shot_on_target_against\n", "94 - gk_psxg_net\n", "95 - gk_passes_completed_launched\n", "96 - gk_passes_launched\n", "97 - gk_passes\n", "98 - gk_passes_throws\n", "99 - gk_goal_kicks\n", "100 - gk_crosses\n", "101 - 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 }