{ "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": [ { "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
AtalantaAtalanta23.049.54.044.0360.08.08.00.00.0...36.047.02.00.00.00.0212.065.060.052.0
BolognaBologna22.056.54.044.0360.03.02.00.01.0...50.040.012.00.01.00.0207.034.046.042.5
CagliariCagliari21.037.84.044.0360.01.01.00.00.0...38.041.05.00.00.00.0220.060.051.054.1
EmpoliEmpoli27.047.84.044.0360.00.00.00.00.0...60.042.08.01.00.00.0203.054.039.058.1
FiorentinaFiorentina22.061.04.044.0360.09.07.00.00.0...56.043.05.01.00.00.0202.056.053.051.4
FrosinoneFrosinone23.048.34.044.0360.07.04.02.02.0...50.039.06.00.02.00.0212.053.052.050.5
GenoaGenoa19.033.34.044.0360.04.03.00.00.0...43.043.09.00.00.00.0200.046.060.043.4
VeronaHellas Verona21.043.54.044.0360.04.02.00.00.0...47.063.07.01.00.00.0190.071.082.046.4
InterInter19.048.84.044.0360.013.011.02.02.0...47.044.05.00.02.00.0163.030.044.040.5
JuventusJuventus21.048.84.044.0360.09.07.01.02.0...52.049.05.00.02.00.0173.026.038.040.6
LazioLazio20.056.04.044.0360.04.04.00.00.0...49.044.07.00.00.00.0196.051.030.063.0
LecceLecce19.043.54.044.0360.07.05.02.02.0...64.053.05.00.02.00.0203.043.054.044.3
MilanMilan19.055.34.044.0360.09.06.03.03.0...56.043.07.01.03.00.0176.042.033.056.0
MonzaMonza22.056.84.044.0360.03.03.00.00.0...37.052.06.01.00.00.0187.045.037.054.9
NapoliNapoli19.061.84.044.0360.08.05.01.02.0...47.039.07.01.02.00.0173.035.047.042.7
RomaRoma23.057.04.044.0360.010.08.01.01.0...46.051.04.01.01.01.0159.054.076.041.5
SalernitanaSalernitana21.051.54.044.0360.03.03.00.00.0...64.046.04.00.00.00.0203.086.054.061.4
SassuoloSassuolo24.043.54.044.0360.05.04.01.01.0...45.034.015.02.01.00.0207.050.037.057.5
TorinoTorino22.051.34.044.0360.05.03.00.00.0...44.048.07.01.00.00.0207.063.059.051.6
UdineseUdinese22.048.54.044.0360.01.01.00.00.0...43.051.010.00.00.00.0188.052.064.044.8
\n", "

20 rows × 303 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 23.0 49.5 4.0 \n", "Bologna Bologna 22.0 56.5 4.0 \n", "Cagliari Cagliari 21.0 37.8 4.0 \n", "Empoli Empoli 27.0 47.8 4.0 \n", "Fiorentina Fiorentina 22.0 61.0 4.0 \n", "Frosinone Frosinone 23.0 48.3 4.0 \n", "Genoa Genoa 19.0 33.3 4.0 \n", "Verona Hellas Verona 21.0 43.5 4.0 \n", "Inter Inter 19.0 48.8 4.0 \n", "Juventus Juventus 21.0 48.8 4.0 \n", "Lazio Lazio 20.0 56.0 4.0 \n", "Lecce Lecce 19.0 43.5 4.0 \n", "Milan Milan 19.0 55.3 4.0 \n", "Monza Monza 22.0 56.8 4.0 \n", "Napoli Napoli 19.0 61.8 4.0 \n", "Roma Roma 23.0 57.0 4.0 \n", "Salernitana Salernitana 21.0 51.5 4.0 \n", "Sassuolo Sassuolo 24.0 43.5 4.0 \n", "Torino Torino 22.0 51.3 4.0 \n", "Udinese Udinese 22.0 48.5 4.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 44.0 360.0 8.0 8.0 \n", "Bologna 44.0 360.0 3.0 2.0 \n", "Cagliari 44.0 360.0 1.0 1.0 \n", "Empoli 44.0 360.0 0.0 0.0 \n", "Fiorentina 44.0 360.0 9.0 7.0 \n", "Frosinone 44.0 360.0 7.0 4.0 \n", "Genoa 44.0 360.0 4.0 3.0 \n", "Verona 44.0 360.0 4.0 2.0 \n", "Inter 44.0 360.0 13.0 11.0 \n", "Juventus 44.0 360.0 9.0 7.0 \n", "Lazio 44.0 360.0 4.0 4.0 \n", "Lecce 44.0 360.0 7.0 5.0 \n", "Milan 44.0 360.0 9.0 6.0 \n", "Monza 44.0 360.0 3.0 3.0 \n", "Napoli 44.0 360.0 8.0 5.0 \n", "Roma 44.0 360.0 10.0 8.0 \n", "Salernitana 44.0 360.0 3.0 3.0 \n", "Sassuolo 44.0 360.0 5.0 4.0 \n", "Torino 44.0 360.0 5.0 3.0 \n", "Udinese 44.0 360.0 1.0 1.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls \\\n", "team_idx ... \n", "Atalanta 0.0 0.0 ... 36.0 \n", "Bologna 0.0 1.0 ... 50.0 \n", "Cagliari 0.0 0.0 ... 38.0 \n", "Empoli 0.0 0.0 ... 60.0 \n", "Fiorentina 0.0 0.0 ... 56.0 \n", "Frosinone 2.0 2.0 ... 50.0 \n", "Genoa 0.0 0.0 ... 43.0 \n", "Verona 0.0 0.0 ... 47.0 \n", "Inter 2.0 2.0 ... 47.0 \n", "Juventus 1.0 2.0 ... 52.0 \n", "Lazio 0.0 0.0 ... 49.0 \n", "Lecce 2.0 2.0 ... 64.0 \n", "Milan 3.0 3.0 ... 56.0 \n", "Monza 0.0 0.0 ... 37.0 \n", "Napoli 1.0 2.0 ... 47.0 \n", "Roma 1.0 1.0 ... 46.0 \n", "Salernitana 0.0 0.0 ... 64.0 \n", "Sassuolo 1.0 1.0 ... 45.0 \n", "Torino 0.0 0.0 ... 44.0 \n", "Udinese 0.0 0.0 ... 43.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 47.0 2.0 0.0 \n", "Bologna 40.0 12.0 0.0 \n", "Cagliari 41.0 5.0 0.0 \n", "Empoli 42.0 8.0 1.0 \n", "Fiorentina 43.0 5.0 1.0 \n", "Frosinone 39.0 6.0 0.0 \n", "Genoa 43.0 9.0 0.0 \n", "Verona 63.0 7.0 1.0 \n", "Inter 44.0 5.0 0.0 \n", "Juventus 49.0 5.0 0.0 \n", "Lazio 44.0 7.0 0.0 \n", "Lecce 53.0 5.0 0.0 \n", "Milan 43.0 7.0 1.0 \n", "Monza 52.0 6.0 1.0 \n", "Napoli 39.0 7.0 1.0 \n", "Roma 51.0 4.0 1.0 \n", "Salernitana 46.0 4.0 0.0 \n", "Sassuolo 34.0 15.0 2.0 \n", "Torino 48.0 7.0 1.0 \n", "Udinese 51.0 10.0 0.0 \n", "\n", " vs_team_pens_conceded vs_team_own_goals \\\n", "team_idx \n", "Atalanta 0.0 0.0 \n", "Bologna 1.0 0.0 \n", "Cagliari 0.0 0.0 \n", "Empoli 0.0 0.0 \n", "Fiorentina 0.0 0.0 \n", "Frosinone 2.0 0.0 \n", "Genoa 0.0 0.0 \n", "Verona 0.0 0.0 \n", "Inter 2.0 0.0 \n", "Juventus 2.0 0.0 \n", "Lazio 0.0 0.0 \n", "Lecce 2.0 0.0 \n", "Milan 3.0 0.0 \n", "Monza 0.0 0.0 \n", "Napoli 2.0 0.0 \n", "Roma 1.0 1.0 \n", "Salernitana 0.0 0.0 \n", "Sassuolo 1.0 0.0 \n", "Torino 0.0 0.0 \n", "Udinese 0.0 0.0 \n", "\n", " vs_team_ball_recoveries vs_team_aerials_won \\\n", "team_idx \n", "Atalanta 212.0 65.0 \n", "Bologna 207.0 34.0 \n", "Cagliari 220.0 60.0 \n", "Empoli 203.0 54.0 \n", "Fiorentina 202.0 56.0 \n", "Frosinone 212.0 53.0 \n", "Genoa 200.0 46.0 \n", "Verona 190.0 71.0 \n", "Inter 163.0 30.0 \n", "Juventus 173.0 26.0 \n", "Lazio 196.0 51.0 \n", "Lecce 203.0 43.0 \n", "Milan 176.0 42.0 \n", "Monza 187.0 45.0 \n", "Napoli 173.0 35.0 \n", "Roma 159.0 54.0 \n", "Salernitana 203.0 86.0 \n", "Sassuolo 207.0 50.0 \n", "Torino 207.0 63.0 \n", "Udinese 188.0 52.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 60.0 52.0 \n", "Bologna 46.0 42.5 \n", "Cagliari 51.0 54.1 \n", "Empoli 39.0 58.1 \n", "Fiorentina 53.0 51.4 \n", "Frosinone 52.0 50.5 \n", "Genoa 60.0 43.4 \n", "Verona 82.0 46.4 \n", "Inter 44.0 40.5 \n", "Juventus 38.0 40.6 \n", "Lazio 30.0 63.0 \n", "Lecce 54.0 44.3 \n", "Milan 33.0 56.0 \n", "Monza 37.0 54.9 \n", "Napoli 47.0 42.7 \n", "Roma 76.0 41.5 \n", "Salernitana 54.0 61.4 \n", "Sassuolo 37.0 57.5 \n", "Torino 59.0 51.6 \n", "Udinese 64.0 44.8 \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.loc[i, 'team_idx'] = team_data.loc[i, 'team_idx'].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
Sommer02428PInterSommerNaN45234-27819880...20.728.34124.900.006.56.0000000.000000
Szczesny1453PJuventusSzczesnyNaN45433-15619900...66.752.03313.000.009.66.7500000.250000
Meret2572PNapoliMeretNaN44026-18319970...0.020.42713.771.7518.25.7500000.250000
Provedel32814PLazioProvedelNaN44829-18819940...20.027.94824.261.5015.76.3750000.414578
Maignan44312PMilanMaignanNaN43828-08019950...60.947.0521223.130.759.86.0000000.000000
..................................................................
Shpendi S.5346395AEmpoliShpendiS36120-12520033...0.00.0000.000.000.05.7500000.250000
Burnete5356418ALecceBurneteNaN5519-23320041...0.00.0000.000.000.06.0000000.000000
Corfitzen5366419ALecceCorfitzenNaN-1000...0.00.0000.000.000.05.7998500.000000
Stewart5376427ASalernitanaStewartNaN-1000...0.00.0000.000.000.06.4476690.000000
Yildiz5386434AJuventusYildizNaN-1000...0.00.0000.000.000.06.4376000.000000
\n", "

539 rows × 160 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID \\\n", "name \n", "Sommer 0 2428 P Inter Sommer NaN 452 \n", "Szczesny 1 453 P Juventus Szczesny NaN 454 \n", "Meret 2 572 P Napoli Meret NaN 440 \n", "Provedel 3 2814 P Lazio Provedel NaN 448 \n", "Maignan 4 4312 P Milan Maignan NaN 438 \n", "... ... ... .. ... ... ... ... \n", "Shpendi S. 534 6395 A Empoli Shpendi S 361 \n", "Burnete 535 6418 A Lecce Burnete NaN 55 \n", "Corfitzen 536 6419 A Lecce Corfitzen NaN -1 \n", "Stewart 537 6427 A Salernitana Stewart NaN -1 \n", "Yildiz 538 6434 A Juventus Yildiz NaN -1 \n", "\n", " age birth_year games ... gk_pct_goal_kicks_launched \\\n", "name ... \n", "Sommer 34-278 1988 0 ... 20.7 \n", "Szczesny 33-156 1990 0 ... 66.7 \n", "Meret 26-183 1997 0 ... 0.0 \n", "Provedel 29-188 1994 0 ... 20.0 \n", "Maignan 28-080 1995 0 ... 60.9 \n", "... ... ... ... ... ... \n", "Shpendi S. 20-125 2003 3 ... 0.0 \n", "Burnete 19-233 2004 1 ... 0.0 \n", "Corfitzen 0 0 0 ... 0.0 \n", "Stewart 0 0 0 ... 0.0 \n", "Yildiz 0 0 0 ... 0.0 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "name \n", "Sommer 28.3 41 2 \n", "Szczesny 52.0 33 1 \n", "Meret 20.4 27 1 \n", "Provedel 27.9 48 2 \n", "Maignan 47.0 52 12 \n", "... ... ... ... \n", "Shpendi S. 0.0 0 0 \n", "Burnete 0.0 0 0 \n", "Corfitzen 0.0 0 0 \n", "Stewart 0.0 0 0 \n", "Yildiz 0.0 0 0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "name \n", "Sommer 4.9 0 \n", "Szczesny 3.0 0 \n", "Meret 3.7 7 \n", "Provedel 4.2 6 \n", "Maignan 23.1 3 \n", "... ... ... \n", "Shpendi S. 0.0 0 \n", "Burnete 0.0 0 \n", "Corfitzen 0.0 0 \n", "Stewart 0.0 0 \n", "Yildiz 0.0 0 \n", "\n", " gk_def_actions_outside_pen_area_per90 \\\n", "name \n", "Sommer 0.00 \n", "Szczesny 0.00 \n", "Meret 1.75 \n", "Provedel 1.50 \n", "Maignan 0.75 \n", "... ... \n", "Shpendi S. 0.00 \n", "Burnete 0.00 \n", "Corfitzen 0.00 \n", "Stewart 0.00 \n", "Yildiz 0.00 \n", "\n", " gk_avg_distance_def_actions vote_avg vote_std \n", "name \n", "Sommer 6.5 6.000000 0.000000 \n", "Szczesny 9.6 6.750000 0.250000 \n", "Meret 18.2 5.750000 0.250000 \n", "Provedel 15.7 6.375000 0.414578 \n", "Maignan 9.8 6.000000 0.000000 \n", "... ... ... ... \n", "Shpendi S. 0.0 5.750000 0.250000 \n", "Burnete 0.0 6.000000 0.000000 \n", "Corfitzen 0.0 5.799850 0.000000 \n", "Stewart 0.0 6.447669 0.000000 \n", "Yildiz 0.0 6.437600 0.000000 \n", "\n", "[539 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
Barella2601870CInterBarellaNaN2326-22619974...36.047.02.00.00.00.0212.065.060.052.0
\n", "

1 rows × 766 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "Barella 260 1870 C Inter Barella NaN 23 26-226 \n", "\n", " birth_year games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Barella 1997 4 ... 36.0 47.0 \n", "\n", " opp_vs_team_offsides opp_vs_team_pens_won \\\n", "Barella 2.0 0.0 \n", "\n", " opp_vs_team_pens_conceded opp_vs_team_own_goals \\\n", "Barella 0.0 0.0 \n", "\n", " opp_vs_team_ball_recoveries opp_vs_team_aerials_won \\\n", "Barella 212.0 65.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Barella 60.0 52.0 \n", "\n", "[1 rows x 766 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data('Barella', 'Inter', 'Atalanta')\n", "test.to_excel('tmp/playermatchdata.xlsx')\n", "\n", "test" ] }, { "cell_type": "code", "execution_count": 7, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Inter'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pteam = 'Inter'\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
BarellaC4428125.00.00.086.2100.048.8...0.0035590.00.0106760.0106760.0071170.00.4946620.0249110.0213520.0
\n", "

1 rows × 112 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct goals_per_shot \\\n", "Barella C 4 4 281 25.0 0.0 \n", "\n", " goals_per_shot_on_target passes_pct aerials_won_pct \\\n", "Barella 0.0 86.2 100.0 \n", "\n", " team_possession ... miscontrols dispossessed fouls fouled \\\n", "Barella 48.8 ... 0.003559 0.0 0.010676 0.010676 \n", "\n", " aerials_won aerials_lost carries progressive_carries \\\n", "Barella 0.007117 0.0 0.494662 0.024911 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "Barella 0.021352 0.0 \n", "\n", "[1 rows x 112 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data_ext('Barella', 'Inter', '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
01MussoAtalantaSassuolo06.5000.06.5
11ZappacostaAtalantaSassuolo06.5000.06.5
21DjimsitiAtalantaSassuolo06.0000.06.0
31KolasinacAtalantaSassuolo06.5000.06.5
41ZorteaAtalantaSassuolo07.0100.010.0
.................................
11544SerdarVeronaBologna16.0000.55.5
11554SuslovVeronaBologna16.0000.55.5
11564BonazzoliVeronaBologna16.0000.06.0
11574DjuricVeronaBologna15.5000.05.5
11584NgongeVeronaBologna15.5000.05.5
\n", "

1159 rows × 10 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Sassuolo 0 6.5 0 0 \n", "1 1 Zappacosta Atalanta Sassuolo 0 6.5 0 0 \n", "2 1 Djimsiti Atalanta Sassuolo 0 6.0 0 0 \n", "3 1 Kolasinac Atalanta Sassuolo 0 6.5 0 0 \n", "4 1 Zortea Atalanta Sassuolo 0 7.0 1 0 \n", "... ... ... ... ... ... ... ... ... \n", "1154 4 Serdar Verona Bologna 1 6.0 0 0 \n", "1155 4 Suslov Verona Bologna 1 6.0 0 0 \n", "1156 4 Bonazzoli Verona Bologna 1 6.0 0 0 \n", "1157 4 Djuric Verona Bologna 1 5.5 0 0 \n", "1158 4 Ngonge Verona Bologna 1 5.5 0 0 \n", "\n", " cards_malus fantavote \n", "0 0.0 6.5 \n", "1 0.0 6.5 \n", "2 0.0 6.0 \n", "3 0.0 6.5 \n", "4 0.0 10.0 \n", "... ... ... \n", "1154 0.5 5.5 \n", "1155 0.5 5.5 \n", "1156 0.0 6.0 \n", "1157 0.0 5.5 \n", "1158 0.0 5.5 \n", "\n", "[1159 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", "600\n", "700\n", "800\n", "900\n", "1000\n", "1100\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
01MussoAtalantaSassuolo06.5000.06.5...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
11ZappacostaAtalantaSassuolo06.5000.06.5...0.0201610.0120970.0120970.0161290.0080650.0161290.3911290.0403230.0201610.012097
21DjimsitiAtalantaSassuolo06.0000.06.0...0.0078740.0000000.0078740.0000000.0196850.0275590.3503940.0000000.0000000.000000
31KolasinacAtalantaSassuolo06.5000.06.5...0.0027860.0027860.0027860.0111420.0139280.0222840.4122560.0194990.0250700.002786
41ZorteaAtalantaSassuolo07.0100.010.0...0.0000000.0208330.0312500.0000000.0000000.0104170.4479170.0625000.0416670.010417
..................................................................
11544SerdarVeronaBologna16.0000.55.5...0.0288460.0096150.0192310.0000000.0096150.0384620.1826920.0000000.0000000.000000
11554SuslovVeronaBologna16.0000.55.5...0.0000000.0000000.0952380.0476190.0000000.0000000.1428570.0000000.0476190.000000
11564BonazzoliVeronaBologna16.0000.06.0...0.0472970.0067570.0067570.0405410.0135140.0202700.3243240.0202700.0135140.013514
11574DjuricVeronaBologna15.5000.05.5...0.0263160.0065790.0460530.0065790.1381580.0921050.1710530.0000000.0131580.000000
11584NgongeVeronaBologna15.5000.05.5...0.0193550.0129030.0322580.0096770.0129030.0225810.2064520.0354840.0129030.016129
\n", "

1159 rows × 122 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Sassuolo 0 6.5 0 0 \n", "1 1 Zappacosta Atalanta Sassuolo 0 6.5 0 0 \n", "2 1 Djimsiti Atalanta Sassuolo 0 6.0 0 0 \n", "3 1 Kolasinac Atalanta Sassuolo 0 6.5 0 0 \n", "4 1 Zortea Atalanta Sassuolo 0 7.0 1 0 \n", "... ... ... ... ... ... ... ... ... \n", "1154 4 Serdar Verona Bologna 1 6.0 0 0 \n", "1155 4 Suslov Verona Bologna 1 6.0 0 0 \n", "1156 4 Bonazzoli Verona Bologna 1 6.0 0 0 \n", "1157 4 Djuric Verona Bologna 1 5.5 0 0 \n", "1158 4 Ngonge Verona Bologna 1 5.5 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "0 0.0 6.5 ... 0.000000 0.000000 0.000000 \n", "1 0.0 6.5 ... 0.020161 0.012097 0.012097 \n", "2 0.0 6.0 ... 0.007874 0.000000 0.007874 \n", "3 0.0 6.5 ... 0.002786 0.002786 0.002786 \n", "4 0.0 10.0 ... 0.000000 0.020833 0.031250 \n", "... ... ... ... ... ... ... \n", "1154 0.5 5.5 ... 0.028846 0.009615 0.019231 \n", "1155 0.5 5.5 ... 0.000000 0.000000 0.095238 \n", "1156 0.0 6.0 ... 0.047297 0.006757 0.006757 \n", "1157 0.0 5.5 ... 0.026316 0.006579 0.046053 \n", "1158 0.0 5.5 ... 0.019355 0.012903 0.032258 \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.016129 0.008065 0.016129 0.391129 0.040323 \n", "2 0.000000 0.019685 0.027559 0.350394 0.000000 \n", "3 0.011142 0.013928 0.022284 0.412256 0.019499 \n", "4 0.000000 0.000000 0.010417 0.447917 0.062500 \n", "... ... ... ... ... ... \n", "1154 0.000000 0.009615 0.038462 0.182692 0.000000 \n", "1155 0.047619 0.000000 0.000000 0.142857 0.000000 \n", "1156 0.040541 0.013514 0.020270 0.324324 0.020270 \n", "1157 0.006579 0.138158 0.092105 0.171053 0.000000 \n", "1158 0.009677 0.012903 0.022581 0.206452 0.035484 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "0 0.000000 0.000000 \n", "1 0.020161 0.012097 \n", "2 0.000000 0.000000 \n", "3 0.025070 0.002786 \n", "4 0.041667 0.010417 \n", "... ... ... \n", "1154 0.000000 0.000000 \n", "1155 0.047619 0.000000 \n", "1156 0.013514 0.013514 \n", "1157 0.013158 0.000000 \n", "1158 0.012903 0.016129 \n", "\n", "[1159 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
11ZappacostaAtalantaSassuolo06.5000.06.5...0.0201610.0120970.0120970.0161290.0080650.0161290.3911290.0403230.0201610.012097
21DjimsitiAtalantaSassuolo06.0000.06.0...0.0078740.0000000.0078740.0000000.0196850.0275590.3503940.0000000.0000000.000000
31KolasinacAtalantaSassuolo06.5000.06.5...0.0027860.0027860.0027860.0111420.0139280.0222840.4122560.0194990.0250700.002786
41ZorteaAtalantaSassuolo07.0100.010.0...0.0000000.0208330.0312500.0000000.0000000.0104170.4479170.0625000.0416670.010417
51RuggeriAtalantaSassuolo06.5010.07.5...0.0123840.0030960.0123840.0061920.0030960.0278640.4086690.0154800.0123840.003096
..................................................................
11544SerdarVeronaBologna16.0000.55.5...0.0288460.0096150.0192310.0000000.0096150.0384620.1826920.0000000.0000000.000000
11554SuslovVeronaBologna16.0000.55.5...0.0000000.0000000.0952380.0476190.0000000.0000000.1428570.0000000.0476190.000000
11564BonazzoliVeronaBologna16.0000.06.0...0.0472970.0067570.0067570.0405410.0135140.0202700.3243240.0202700.0135140.013514
11574DjuricVeronaBologna15.5000.05.5...0.0263160.0065790.0460530.0065790.1381580.0921050.1710530.0000000.0131580.000000
11584NgongeVeronaBologna15.5000.05.5...0.0193550.0129030.0322580.0096770.0129030.0225810.2064520.0354840.0129030.016129
\n", "

1070 rows × 122 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "1 1 Zappacosta Atalanta Sassuolo 0 6.5 0 0 \n", "2 1 Djimsiti Atalanta Sassuolo 0 6.0 0 0 \n", "3 1 Kolasinac Atalanta Sassuolo 0 6.5 0 0 \n", "4 1 Zortea Atalanta Sassuolo 0 7.0 1 0 \n", "5 1 Ruggeri Atalanta Sassuolo 0 6.5 0 1 \n", "... ... ... ... ... ... ... ... ... \n", "1154 4 Serdar Verona Bologna 1 6.0 0 0 \n", "1155 4 Suslov Verona Bologna 1 6.0 0 0 \n", "1156 4 Bonazzoli Verona Bologna 1 6.0 0 0 \n", "1157 4 Djuric Verona Bologna 1 5.5 0 0 \n", "1158 4 Ngonge Verona Bologna 1 5.5 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "1 0.0 6.5 ... 0.020161 0.012097 0.012097 \n", "2 0.0 6.0 ... 0.007874 0.000000 0.007874 \n", "3 0.0 6.5 ... 0.002786 0.002786 0.002786 \n", "4 0.0 10.0 ... 0.000000 0.020833 0.031250 \n", "5 0.0 7.5 ... 0.012384 0.003096 0.012384 \n", "... ... ... ... ... ... ... \n", "1154 0.5 5.5 ... 0.028846 0.009615 0.019231 \n", "1155 0.5 5.5 ... 0.000000 0.000000 0.095238 \n", "1156 0.0 6.0 ... 0.047297 0.006757 0.006757 \n", "1157 0.0 5.5 ... 0.026316 0.006579 0.046053 \n", "1158 0.0 5.5 ... 0.019355 0.012903 0.032258 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "1 0.016129 0.008065 0.016129 0.391129 0.040323 \n", "2 0.000000 0.019685 0.027559 0.350394 0.000000 \n", "3 0.011142 0.013928 0.022284 0.412256 0.019499 \n", "4 0.000000 0.000000 0.010417 0.447917 0.062500 \n", "5 0.006192 0.003096 0.027864 0.408669 0.015480 \n", "... ... ... ... ... ... \n", "1154 0.000000 0.009615 0.038462 0.182692 0.000000 \n", "1155 0.047619 0.000000 0.000000 0.142857 0.000000 \n", "1156 0.040541 0.013514 0.020270 0.324324 0.020270 \n", "1157 0.006579 0.138158 0.092105 0.171053 0.000000 \n", "1158 0.009677 0.012903 0.022581 0.206452 0.035484 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "1 0.020161 0.012097 \n", "2 0.000000 0.000000 \n", "3 0.025070 0.002786 \n", "4 0.041667 0.010417 \n", "5 0.012384 0.003096 \n", "... ... ... \n", "1154 0.000000 0.000000 \n", "1155 0.047619 0.000000 \n", "1156 0.013514 0.013514 \n", "1157 0.013158 0.000000 \n", "1158 0.012903 0.016129 \n", "\n", "[1070 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
Consigli332701.6766.70.0-0.5823.938.937.1...3.30.19-1.711.046.095.010.034.046.02.0
\n", "

1 rows × 92 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 3 3 270 1.67 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 66.7 0.0 -0.58 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 23.9 38.9 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 37.1 ... 3.3 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.19 -1.7 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 11.0 46.0 95.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 10.0 34.0 46.0 2.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" ] } ], "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
01MussoAtalantaSassuolo06.5000.06.5...2.10.210.111.034.088.018.018.028.02.0
11ZappacostaAtalantaSassuolo06.5000.06.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
21DjimsitiAtalantaSassuolo06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
31KolasinacAtalantaSassuolo06.5000.06.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
41ZorteaAtalantaSassuolo07.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
11544SerdarVeronaBologna16.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
11554SuslovVeronaBologna16.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
11564BonazzoliVeronaBologna16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
11574DjuricVeronaBologna15.5000.05.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
11584NgongeVeronaBologna15.5000.05.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

1159 rows × 102 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Sassuolo 0 6.5 0 0 \n", "1 1 Zappacosta Atalanta Sassuolo 0 6.5 0 0 \n", "2 1 Djimsiti Atalanta Sassuolo 0 6.0 0 0 \n", "3 1 Kolasinac Atalanta Sassuolo 0 6.5 0 0 \n", "4 1 Zortea Atalanta Sassuolo 0 7.0 1 0 \n", "... ... ... ... ... ... ... ... ... \n", "1154 4 Serdar Verona Bologna 1 6.0 0 0 \n", "1155 4 Suslov Verona Bologna 1 6.0 0 0 \n", "1156 4 Bonazzoli Verona Bologna 1 6.0 0 0 \n", "1157 4 Djuric Verona Bologna 1 5.5 0 0 \n", "1158 4 Ngonge Verona Bologna 1 5.5 0 0 \n", "\n", " cards_malus fantavote ... gk_psxg \\\n", "0 0.0 6.5 ... 2.1 \n", "1 0.0 6.5 ... NaN \n", "2 0.0 6.0 ... NaN \n", "3 0.0 6.5 ... NaN \n", "4 0.0 10.0 ... NaN \n", "... ... ... ... ... \n", "1154 0.5 5.5 ... NaN \n", "1155 0.5 5.5 ... NaN \n", "1156 0.0 6.0 ... NaN \n", "1157 0.0 5.5 ... NaN \n", "1158 0.0 5.5 ... NaN \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.21 0.1 \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "... ... ... \n", "1154 NaN NaN \n", "1155 NaN NaN \n", "1156 NaN NaN \n", "1157 NaN NaN \n", "1158 NaN NaN \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 11.0 34.0 88.0 \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "1154 NaN NaN NaN \n", "1155 NaN NaN NaN \n", "1156 NaN NaN NaN \n", "1157 NaN NaN NaN \n", "1158 NaN NaN NaN \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 18.0 18.0 28.0 2.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", "1154 NaN NaN NaN NaN \n", "1155 NaN NaN NaN NaN \n", "1156 NaN NaN NaN NaN \n", "1157 NaN NaN NaN NaN \n", "1158 NaN NaN NaN NaN \n", "\n", "[1159 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
01MussoAtalantaSassuolo06.5000.06.5...2.10.210.111.034.088.018.018.028.02.0
161SkorupskiBolognaMilan16.0-200.04.0...3.20.32-0.817.045.0106.017.022.057.02.0
291RadunovicCagliariTorino06.5000.06.5...4.10.330.124.054.076.018.040.062.04.0
441CaprileEmpoliVerona15.0-100.04.0...0.40.11-0.64.020.037.09.04.010.02.0
571TerraccianoFiorentinaGenoa06.0-100.05.0...1.00.17-2.013.020.085.010.09.016.01.0
..................................................................
10854OchoaSalernitanaTorino15.0-300.02.0...4.70.21-3.313.055.089.014.035.063.04.0
11014CragnoSassuoloFrosinone06.5-400.02.5...2.80.30-1.25.015.024.03.09.09.00.0
11174Milinkovic-Savic V.TorinoSalernitana06.0000.06.0...4.60.180.629.079.0117.023.036.033.03.0
11294SilvestriUdineseCagliari06.0000.06.0...3.90.29-0.111.034.094.014.032.049.00.0
11434Montipo'VeronaBologna17.0000.07.0...4.90.190.935.093.0109.08.035.054.01.0
\n", "

80 rows × 102 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote \\\n", "0 1 Musso Atalanta Sassuolo 0 6.5 \n", "16 1 Skorupski Bologna Milan 1 6.0 \n", "29 1 Radunovic Cagliari Torino 0 6.5 \n", "44 1 Caprile Empoli Verona 1 5.0 \n", "57 1 Terracciano Fiorentina Genoa 0 6.0 \n", "... ... ... ... ... ... ... \n", "1085 4 Ochoa Salernitana Torino 1 5.0 \n", "1101 4 Cragno Sassuolo Frosinone 0 6.5 \n", "1117 4 Milinkovic-Savic V. Torino Salernitana 0 6.0 \n", "1129 4 Silvestri Udinese Cagliari 0 6.0 \n", "1143 4 Montipo' Verona Bologna 1 7.0 \n", "\n", " goals assists cards_malus fantavote ... gk_psxg \\\n", "0 0 0 0.0 6.5 ... 2.1 \n", "16 -2 0 0.0 4.0 ... 3.2 \n", "29 0 0 0.0 6.5 ... 4.1 \n", "44 -1 0 0.0 4.0 ... 0.4 \n", "57 -1 0 0.0 5.0 ... 1.0 \n", "... ... ... ... ... ... ... \n", "1085 -3 0 0.0 2.0 ... 4.7 \n", "1101 -4 0 0.0 2.5 ... 2.8 \n", "1117 0 0 0.0 6.0 ... 4.6 \n", "1129 0 0 0.0 6.0 ... 3.9 \n", "1143 0 0 0.0 7.0 ... 4.9 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.21 0.1 \n", "16 0.32 -0.8 \n", "29 0.33 0.1 \n", "44 0.11 -0.6 \n", "57 0.17 -2.0 \n", "... ... ... \n", "1085 0.21 -3.3 \n", "1101 0.30 -1.2 \n", "1117 0.18 0.6 \n", "1129 0.29 -0.1 \n", "1143 0.19 0.9 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 11.0 34.0 88.0 \n", "16 17.0 45.0 106.0 \n", "29 24.0 54.0 76.0 \n", "44 4.0 20.0 37.0 \n", "57 13.0 20.0 85.0 \n", "... ... ... ... \n", "1085 13.0 55.0 89.0 \n", "1101 5.0 15.0 24.0 \n", "1117 29.0 79.0 117.0 \n", "1129 11.0 34.0 94.0 \n", "1143 35.0 93.0 109.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 18.0 18.0 28.0 2.0 \n", "16 17.0 22.0 57.0 2.0 \n", "29 18.0 40.0 62.0 4.0 \n", "44 9.0 4.0 10.0 2.0 \n", "57 10.0 9.0 16.0 1.0 \n", "... ... ... ... ... \n", "1085 14.0 35.0 63.0 4.0 \n", "1101 3.0 9.0 9.0 0.0 \n", "1117 23.0 36.0 33.0 3.0 \n", "1129 14.0 32.0 49.0 0.0 \n", "1143 8.0 35.0 54.0 1.0 \n", "\n", "[80 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]))" ] } ], "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 }