{ "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": 2, "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": 3, "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
AtalantaAtalanta24.050.56.066.0540.011.011.00.00.0...57.074.04.00.00.00.0347.097.0109.047.1
BolognaBologna23.054.76.066.0540.03.02.00.01.0...71.070.016.00.01.00.0292.047.073.039.2
CagliariCagliari22.038.26.066.0540.02.02.00.00.0...50.065.011.00.00.00.0332.092.071.056.4
EmpoliEmpoli28.045.36.066.0540.01.01.00.00.0...84.074.010.01.00.00.0313.082.060.057.7
FiorentinaFiorentina24.057.26.066.0540.012.09.00.00.0...75.063.08.01.00.00.0311.096.075.056.1
FrosinoneFrosinone24.049.26.066.0540.09.05.02.02.0...73.054.015.00.02.00.0325.079.080.049.7
GenoaGenoa22.034.36.066.0540.08.07.00.00.0...67.060.012.00.00.00.0295.066.083.044.3
VeronaHellas Verona22.045.26.066.0540.04.02.00.00.0...84.084.011.01.00.00.0326.0116.0117.049.8
InterInter22.053.26.066.0540.015.012.02.02.0...70.064.09.00.02.00.0248.046.077.037.4
JuventusJuventus22.050.36.066.0540.011.09.01.02.0...80.071.06.00.02.01.0267.041.067.038.0
LazioLazio20.054.06.066.0540.07.06.01.01.0...69.067.010.00.01.00.0282.066.053.055.5
LecceLecce22.046.76.066.0540.08.06.02.02.0...88.078.05.00.02.00.0295.067.073.047.9
MilanMilan23.056.86.066.0540.013.08.03.03.0...80.060.08.01.03.00.0281.065.061.051.6
MonzaMonza23.054.26.066.0540.04.03.00.00.0...65.068.011.02.00.00.0281.074.056.056.9
NapoliNapoli20.060.76.066.0540.012.07.02.04.0...73.060.09.01.04.00.0254.052.056.048.1
RomaRoma23.059.76.066.0540.012.09.01.01.0...58.067.04.01.01.01.0267.083.0104.044.4
SalernitanaSalernitana22.052.36.066.0540.04.03.00.00.0...94.070.012.00.00.00.0311.0120.082.059.4
SassuoloSassuolo25.042.36.066.0540.010.07.01.01.0...63.055.020.02.01.01.0299.085.055.060.7
TorinoTorino23.049.26.066.0540.06.04.00.00.0...61.064.07.01.00.00.0302.093.082.053.1
UdineseUdinese24.046.26.066.0540.02.02.00.00.0...65.074.011.01.00.00.0297.068.0101.040.2
\n", "

20 rows × 303 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 24.0 50.5 6.0 \n", "Bologna Bologna 23.0 54.7 6.0 \n", "Cagliari Cagliari 22.0 38.2 6.0 \n", "Empoli Empoli 28.0 45.3 6.0 \n", "Fiorentina Fiorentina 24.0 57.2 6.0 \n", "Frosinone Frosinone 24.0 49.2 6.0 \n", "Genoa Genoa 22.0 34.3 6.0 \n", "Verona Hellas Verona 22.0 45.2 6.0 \n", "Inter Inter 22.0 53.2 6.0 \n", "Juventus Juventus 22.0 50.3 6.0 \n", "Lazio Lazio 20.0 54.0 6.0 \n", "Lecce Lecce 22.0 46.7 6.0 \n", "Milan Milan 23.0 56.8 6.0 \n", "Monza Monza 23.0 54.2 6.0 \n", "Napoli Napoli 20.0 60.7 6.0 \n", "Roma Roma 23.0 59.7 6.0 \n", "Salernitana Salernitana 22.0 52.3 6.0 \n", "Sassuolo Sassuolo 25.0 42.3 6.0 \n", "Torino Torino 23.0 49.2 6.0 \n", "Udinese Udinese 24.0 46.2 6.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 66.0 540.0 11.0 11.0 \n", "Bologna 66.0 540.0 3.0 2.0 \n", "Cagliari 66.0 540.0 2.0 2.0 \n", "Empoli 66.0 540.0 1.0 1.0 \n", "Fiorentina 66.0 540.0 12.0 9.0 \n", "Frosinone 66.0 540.0 9.0 5.0 \n", "Genoa 66.0 540.0 8.0 7.0 \n", "Verona 66.0 540.0 4.0 2.0 \n", "Inter 66.0 540.0 15.0 12.0 \n", "Juventus 66.0 540.0 11.0 9.0 \n", "Lazio 66.0 540.0 7.0 6.0 \n", "Lecce 66.0 540.0 8.0 6.0 \n", "Milan 66.0 540.0 13.0 8.0 \n", "Monza 66.0 540.0 4.0 3.0 \n", "Napoli 66.0 540.0 12.0 7.0 \n", "Roma 66.0 540.0 12.0 9.0 \n", "Salernitana 66.0 540.0 4.0 3.0 \n", "Sassuolo 66.0 540.0 10.0 7.0 \n", "Torino 66.0 540.0 6.0 4.0 \n", "Udinese 66.0 540.0 2.0 2.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls \\\n", "team_idx ... \n", "Atalanta 0.0 0.0 ... 57.0 \n", "Bologna 0.0 1.0 ... 71.0 \n", "Cagliari 0.0 0.0 ... 50.0 \n", "Empoli 0.0 0.0 ... 84.0 \n", "Fiorentina 0.0 0.0 ... 75.0 \n", "Frosinone 2.0 2.0 ... 73.0 \n", "Genoa 0.0 0.0 ... 67.0 \n", "Verona 0.0 0.0 ... 84.0 \n", "Inter 2.0 2.0 ... 70.0 \n", "Juventus 1.0 2.0 ... 80.0 \n", "Lazio 1.0 1.0 ... 69.0 \n", "Lecce 2.0 2.0 ... 88.0 \n", "Milan 3.0 3.0 ... 80.0 \n", "Monza 0.0 0.0 ... 65.0 \n", "Napoli 2.0 4.0 ... 73.0 \n", "Roma 1.0 1.0 ... 58.0 \n", "Salernitana 0.0 0.0 ... 94.0 \n", "Sassuolo 1.0 1.0 ... 63.0 \n", "Torino 0.0 0.0 ... 61.0 \n", "Udinese 0.0 0.0 ... 65.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 74.0 4.0 0.0 \n", "Bologna 70.0 16.0 0.0 \n", "Cagliari 65.0 11.0 0.0 \n", "Empoli 74.0 10.0 1.0 \n", "Fiorentina 63.0 8.0 1.0 \n", "Frosinone 54.0 15.0 0.0 \n", "Genoa 60.0 12.0 0.0 \n", "Verona 84.0 11.0 1.0 \n", "Inter 64.0 9.0 0.0 \n", "Juventus 71.0 6.0 0.0 \n", "Lazio 67.0 10.0 0.0 \n", "Lecce 78.0 5.0 0.0 \n", "Milan 60.0 8.0 1.0 \n", "Monza 68.0 11.0 2.0 \n", "Napoli 60.0 9.0 1.0 \n", "Roma 67.0 4.0 1.0 \n", "Salernitana 70.0 12.0 0.0 \n", "Sassuolo 55.0 20.0 2.0 \n", "Torino 64.0 7.0 1.0 \n", "Udinese 74.0 11.0 1.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 1.0 \n", "Lazio 1.0 0.0 \n", "Lecce 2.0 0.0 \n", "Milan 3.0 0.0 \n", "Monza 0.0 0.0 \n", "Napoli 4.0 0.0 \n", "Roma 1.0 1.0 \n", "Salernitana 0.0 0.0 \n", "Sassuolo 1.0 1.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 347.0 97.0 \n", "Bologna 292.0 47.0 \n", "Cagliari 332.0 92.0 \n", "Empoli 313.0 82.0 \n", "Fiorentina 311.0 96.0 \n", "Frosinone 325.0 79.0 \n", "Genoa 295.0 66.0 \n", "Verona 326.0 116.0 \n", "Inter 248.0 46.0 \n", "Juventus 267.0 41.0 \n", "Lazio 282.0 66.0 \n", "Lecce 295.0 67.0 \n", "Milan 281.0 65.0 \n", "Monza 281.0 74.0 \n", "Napoli 254.0 52.0 \n", "Roma 267.0 83.0 \n", "Salernitana 311.0 120.0 \n", "Sassuolo 299.0 85.0 \n", "Torino 302.0 93.0 \n", "Udinese 297.0 68.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 109.0 47.1 \n", "Bologna 73.0 39.2 \n", "Cagliari 71.0 56.4 \n", "Empoli 60.0 57.7 \n", "Fiorentina 75.0 56.1 \n", "Frosinone 80.0 49.7 \n", "Genoa 83.0 44.3 \n", "Verona 117.0 49.8 \n", "Inter 77.0 37.4 \n", "Juventus 67.0 38.0 \n", "Lazio 53.0 55.5 \n", "Lecce 73.0 47.9 \n", "Milan 61.0 51.6 \n", "Monza 56.0 56.9 \n", "Napoli 56.0 48.1 \n", "Roma 104.0 44.4 \n", "Salernitana 82.0 59.4 \n", "Sassuolo 55.0 60.7 \n", "Torino 82.0 53.1 \n", "Udinese 101.0 40.2 \n", "\n", "[20 rows x 303 columns]" ] }, "execution_count": 3, "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": 4, "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": 5, "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
Sommer02428PInterSommerNaN48134-28719880...20.527.359.05.08.52.00.339.65.8333330.372678
Szczesny1453PJuventusSzczesnyNaN48433-16519900...50.045.859.01.01.71.00.258.55.8750001.138804
Meret2572PNapoliMeretNaN46926-19219970...0.020.553.01.01.98.01.3317.25.8333330.235702
Provedel32814PLazioProvedelNaN47729-19719940...27.632.363.03.04.87.01.1716.06.4166670.448764
Maignan44312PMilanMaignanNaN46728-08919950...60.947.052.012.023.13.00.759.86.0000000.000000
..................................................................
Shpendi S.5346395AEmpoliShpendiS38720-13420035...0.00.00.00.00.00.00.000.05.8750000.216506
Burnete5356418ALecceBurneteNaN5919-24220041...0.00.00.00.00.00.00.000.06.2111570.443859
Corfitzen5366419ALecceCorfitzenNaN-1000...0.00.00.00.00.00.00.000.05.4820510.490718
Stewart5376427ASalernitanaStewartNaN-1000...0.00.00.00.00.00.00.000.06.0399740.448371
Yildiz5386434AJuventusYildizNaN-1000...0.00.00.00.00.00.00.000.05.6010150.337620
\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 481 \n", "Szczesny 1 453 P Juventus Szczesny NaN 484 \n", "Meret 2 572 P Napoli Meret NaN 469 \n", "Provedel 3 2814 P Lazio Provedel NaN 477 \n", "Maignan 4 4312 P Milan Maignan NaN 467 \n", "... ... ... .. ... ... ... ... \n", "Shpendi S. 534 6395 A Empoli Shpendi S 387 \n", "Burnete 535 6418 A Lecce Burnete NaN 59 \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-287 1988 0 ... 20.5 \n", "Szczesny 33-165 1990 0 ... 50.0 \n", "Meret 26-192 1997 0 ... 0.0 \n", "Provedel 29-197 1994 0 ... 27.6 \n", "Maignan 28-089 1995 0 ... 60.9 \n", "... ... ... ... ... ... \n", "Shpendi S. 20-134 2003 5 ... 0.0 \n", "Burnete 19-242 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 27.3 59.0 5.0 \n", "Szczesny 45.8 59.0 1.0 \n", "Meret 20.5 53.0 1.0 \n", "Provedel 32.3 63.0 3.0 \n", "Maignan 47.0 52.0 12.0 \n", "... ... ... ... \n", "Shpendi S. 0.0 0.0 0.0 \n", "Burnete 0.0 0.0 0.0 \n", "Corfitzen 0.0 0.0 0.0 \n", "Stewart 0.0 0.0 0.0 \n", "Yildiz 0.0 0.0 0.0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "name \n", "Sommer 8.5 2.0 \n", "Szczesny 1.7 1.0 \n", "Meret 1.9 8.0 \n", "Provedel 4.8 7.0 \n", "Maignan 23.1 3.0 \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_def_actions_outside_pen_area_per90 \\\n", "name \n", "Sommer 0.33 \n", "Szczesny 0.25 \n", "Meret 1.33 \n", "Provedel 1.17 \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 9.6 5.833333 0.372678 \n", "Szczesny 8.5 5.875000 1.138804 \n", "Meret 17.2 5.833333 0.235702 \n", "Provedel 16.0 6.416667 0.448764 \n", "Maignan 9.8 6.000000 0.000000 \n", "... ... ... ... \n", "Shpendi S. 0.0 5.875000 0.216506 \n", "Burnete 0.0 6.211157 0.443859 \n", "Corfitzen 0.0 5.482051 0.490718 \n", "Stewart 0.0 6.039974 0.448371 \n", "Yildiz 0.0 5.601015 0.337620 \n", "\n", "[539 rows x 160 columns]" ] }, "execution_count": 5, "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": 6, "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": 7, "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
Barella2601870CInterBarellaNaN2526-23519976...57.074.04.00.00.00.0347.097.0109.047.1
\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 25 26-235 \n", "\n", " birth_year games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Barella 1997 6 ... 57.0 74.0 \n", "\n", " opp_vs_team_offsides opp_vs_team_pens_won \\\n", "Barella 4.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 347.0 97.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Barella 109.0 47.1 \n", "\n", "[1 rows x 766 columns]" ] }, "execution_count": 7, "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": 8, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Inter'" ] }, "execution_count": 8, "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": 9, "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": 9, "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": 10, "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": 11, "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": 12, "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
BarellaC6539114.30.00.085.966.753.2...0.0127880.0051150.0076730.0076730.0051150.0025580.5345270.0281330.020460.0
\n", "

1 rows × 112 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct goals_per_shot \\\n", "Barella C 6 5 391 14.3 0.0 \n", "\n", " goals_per_shot_on_target passes_pct aerials_won_pct \\\n", "Barella 0.0 85.9 66.7 \n", "\n", " team_possession ... miscontrols dispossessed fouls fouled \\\n", "Barella 53.2 ... 0.012788 0.005115 0.007673 0.007673 \n", "\n", " aerials_won aerials_lost carries progressive_carries \\\n", "Barella 0.005115 0.002558 0.534527 0.028133 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "Barella 0.02046 0.0 \n", "\n", "[1 rows x 112 columns]" ] }, "execution_count": 12, "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": 13, "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
.................................
17266FolorunshoVeronaAtalanta16.0000.55.5
17276SuslovVeronaAtalanta16.0000.06.0
17286BonazzoliVeronaAtalanta15.5000.05.5
17296HenryVeronaAtalanta16.0000.06.0
17306NgongeVeronaAtalanta15.0000.54.5
\n", "

1731 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", "1726 6 Folorunsho Verona Atalanta 1 6.0 0 0 \n", "1727 6 Suslov Verona Atalanta 1 6.0 0 0 \n", "1728 6 Bonazzoli Verona Atalanta 1 5.5 0 0 \n", "1729 6 Henry Verona Atalanta 1 6.0 0 0 \n", "1730 6 Ngonge Verona Atalanta 1 5.0 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", "1726 0.5 5.5 \n", "1727 0.0 6.0 \n", "1728 0.0 5.5 \n", "1729 0.0 6.0 \n", "1730 0.5 4.5 \n", "\n", "[1731 rows x 10 columns]" ] }, "execution_count": 13, "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": 14, "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", "1200\n", "1300\n", "1400\n", "1500\n", "1600\n", "1700\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": 15, "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.0183490.0091740.0091740.0152910.0091740.0152910.3761470.0336390.0152910.012232
21DjimsitiAtalantaSassuolo06.0000.06.0...0.0046080.0000000.0115210.0023040.0345620.0207370.2995390.0000000.0000000.000000
31KolasinacAtalantaSassuolo06.5000.06.5...0.0092760.0018550.0092760.0148420.0166980.0222630.3784790.0148420.0166980.001855
41ZorteaAtalantaSassuolo07.0100.010.0...0.0000000.0208330.0312500.0000000.0000000.0104170.4479170.0625000.0416670.010417
..................................................................
17266FolorunshoVeronaAtalanta16.0000.55.5...0.0182190.0080970.0161940.0303640.0222670.0445340.2287450.0101210.0121460.000000
17276SuslovVeronaAtalanta16.0000.06.0...0.0151520.0303030.0303030.0303030.0151520.0000000.2878790.0000000.0303030.000000
17286BonazzoliVeronaAtalanta15.5000.05.5...0.0481930.0160640.0080320.0281120.0120480.0200800.2891570.0120480.0160640.008032
17296HenryVeronaAtalanta16.0000.06.0...0.0555560.0000000.0555560.0555560.0555560.1111110.2777780.0000000.0555560.000000
17306NgongeVeronaAtalanta15.0000.54.5...0.0303690.0086770.0282000.0108460.0238610.0412150.2212580.0260300.0130150.013015
\n", "

1731 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", "1726 6 Folorunsho Verona Atalanta 1 6.0 0 0 \n", "1727 6 Suslov Verona Atalanta 1 6.0 0 0 \n", "1728 6 Bonazzoli Verona Atalanta 1 5.5 0 0 \n", "1729 6 Henry Verona Atalanta 1 6.0 0 0 \n", "1730 6 Ngonge Verona Atalanta 1 5.0 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.018349 0.009174 0.009174 \n", "2 0.0 6.0 ... 0.004608 0.000000 0.011521 \n", "3 0.0 6.5 ... 0.009276 0.001855 0.009276 \n", "4 0.0 10.0 ... 0.000000 0.020833 0.031250 \n", "... ... ... ... ... ... ... \n", "1726 0.5 5.5 ... 0.018219 0.008097 0.016194 \n", "1727 0.0 6.0 ... 0.015152 0.030303 0.030303 \n", "1728 0.0 5.5 ... 0.048193 0.016064 0.008032 \n", "1729 0.0 6.0 ... 0.055556 0.000000 0.055556 \n", "1730 0.5 4.5 ... 0.030369 0.008677 0.028200 \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.015291 0.009174 0.015291 0.376147 0.033639 \n", "2 0.002304 0.034562 0.020737 0.299539 0.000000 \n", "3 0.014842 0.016698 0.022263 0.378479 0.014842 \n", "4 0.000000 0.000000 0.010417 0.447917 0.062500 \n", "... ... ... ... ... ... \n", "1726 0.030364 0.022267 0.044534 0.228745 0.010121 \n", "1727 0.030303 0.015152 0.000000 0.287879 0.000000 \n", "1728 0.028112 0.012048 0.020080 0.289157 0.012048 \n", "1729 0.055556 0.055556 0.111111 0.277778 0.000000 \n", "1730 0.010846 0.023861 0.041215 0.221258 0.026030 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "0 0.000000 0.000000 \n", "1 0.015291 0.012232 \n", "2 0.000000 0.000000 \n", "3 0.016698 0.001855 \n", "4 0.041667 0.010417 \n", "... ... ... \n", "1726 0.012146 0.000000 \n", "1727 0.030303 0.000000 \n", "1728 0.016064 0.008032 \n", "1729 0.055556 0.000000 \n", "1730 0.013015 0.013015 \n", "\n", "[1731 rows x 122 columns]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "markdown", "id": "d237f87b", "metadata": {}, "source": [ "Remove undesired database entries." ] }, { "cell_type": "code", "execution_count": 16, "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": 17, "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.0183490.0091740.0091740.0152910.0091740.0152910.3761470.0336390.0152910.012232
21DjimsitiAtalantaSassuolo06.0000.06.0...0.0046080.0000000.0115210.0023040.0345620.0207370.2995390.0000000.0000000.000000
31KolasinacAtalantaSassuolo06.5000.06.5...0.0092760.0018550.0092760.0148420.0166980.0222630.3784790.0148420.0166980.001855
41ZorteaAtalantaSassuolo07.0100.010.0...0.0000000.0208330.0312500.0000000.0000000.0104170.4479170.0625000.0416670.010417
51RuggeriAtalantaSassuolo06.5010.07.5...0.0102040.0020410.0142860.0040820.0102040.0204080.3571430.0163270.0142860.004082
..................................................................
17266FolorunshoVeronaAtalanta16.0000.55.5...0.0182190.0080970.0161940.0303640.0222670.0445340.2287450.0101210.0121460.000000
17276SuslovVeronaAtalanta16.0000.06.0...0.0151520.0303030.0303030.0303030.0151520.0000000.2878790.0000000.0303030.000000
17286BonazzoliVeronaAtalanta15.5000.05.5...0.0481930.0160640.0080320.0281120.0120480.0200800.2891570.0120480.0160640.008032
17296HenryVeronaAtalanta16.0000.06.0...0.0555560.0000000.0555560.0555560.0555560.1111110.2777780.0000000.0555560.000000
17306NgongeVeronaAtalanta15.0000.54.5...0.0303690.0086770.0282000.0108460.0238610.0412150.2212580.0260300.0130150.013015
\n", "

1601 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", "1726 6 Folorunsho Verona Atalanta 1 6.0 0 0 \n", "1727 6 Suslov Verona Atalanta 1 6.0 0 0 \n", "1728 6 Bonazzoli Verona Atalanta 1 5.5 0 0 \n", "1729 6 Henry Verona Atalanta 1 6.0 0 0 \n", "1730 6 Ngonge Verona Atalanta 1 5.0 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "1 0.0 6.5 ... 0.018349 0.009174 0.009174 \n", "2 0.0 6.0 ... 0.004608 0.000000 0.011521 \n", "3 0.0 6.5 ... 0.009276 0.001855 0.009276 \n", "4 0.0 10.0 ... 0.000000 0.020833 0.031250 \n", "5 0.0 7.5 ... 0.010204 0.002041 0.014286 \n", "... ... ... ... ... ... ... \n", "1726 0.5 5.5 ... 0.018219 0.008097 0.016194 \n", "1727 0.0 6.0 ... 0.015152 0.030303 0.030303 \n", "1728 0.0 5.5 ... 0.048193 0.016064 0.008032 \n", "1729 0.0 6.0 ... 0.055556 0.000000 0.055556 \n", "1730 0.5 4.5 ... 0.030369 0.008677 0.028200 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "1 0.015291 0.009174 0.015291 0.376147 0.033639 \n", "2 0.002304 0.034562 0.020737 0.299539 0.000000 \n", "3 0.014842 0.016698 0.022263 0.378479 0.014842 \n", "4 0.000000 0.000000 0.010417 0.447917 0.062500 \n", "5 0.004082 0.010204 0.020408 0.357143 0.016327 \n", "... ... ... ... ... ... \n", "1726 0.030364 0.022267 0.044534 0.228745 0.010121 \n", "1727 0.030303 0.015152 0.000000 0.287879 0.000000 \n", "1728 0.028112 0.012048 0.020080 0.289157 0.012048 \n", "1729 0.055556 0.055556 0.111111 0.277778 0.000000 \n", "1730 0.010846 0.023861 0.041215 0.221258 0.026030 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "1 0.015291 0.012232 \n", "2 0.000000 0.000000 \n", "3 0.016698 0.001855 \n", "4 0.041667 0.010417 \n", "5 0.014286 0.004082 \n", "... ... ... \n", "1726 0.012146 0.000000 \n", "1727 0.030303 0.000000 \n", "1728 0.016064 0.008032 \n", "1729 0.055556 0.000000 \n", "1730 0.013015 0.013015 \n", "\n", "[1601 rows x 122 columns]" ] }, "execution_count": 17, "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": 18, "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": 19, "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": 20, "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": 20, "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": 21, "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": 22, "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": 23, "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
Consigli4.04.03601.566.70.0-0.4726.145.739.4...4.10.21-1.918.069.0127.014.042.073.04.0
\n", "

1 rows × 92 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 4.0 4.0 360 1.5 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 66.7 0.0 -0.47 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 26.1 45.7 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 39.4 ... 4.1 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.21 -1.9 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 18.0 69.0 127.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 14.0 42.0 73.0 4.0 \n", "\n", "[1 rows x 92 columns]" ] }, "execution_count": 23, "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": 24, "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" ] } ], "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": 25, "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.114.048.0119.025.028.043.04.0
11ZappacostaAtalantaSassuolo06.5000.06.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
21DjimsitiAtalantaSassuolo06.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
31KolasinacAtalantaSassuolo06.5000.06.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
41ZorteaAtalantaSassuolo07.0100.010.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
17266FolorunshoVeronaAtalanta16.0000.55.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
17276SuslovVeronaAtalanta16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
17286BonazzoliVeronaAtalanta15.5000.05.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
17296HenryVeronaAtalanta16.0000.06.0...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
17306NgongeVeronaAtalanta15.0000.54.5...NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

1731 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", "1726 6 Folorunsho Verona Atalanta 1 6.0 0 0 \n", "1727 6 Suslov Verona Atalanta 1 6.0 0 0 \n", "1728 6 Bonazzoli Verona Atalanta 1 5.5 0 0 \n", "1729 6 Henry Verona Atalanta 1 6.0 0 0 \n", "1730 6 Ngonge Verona Atalanta 1 5.0 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", "1726 0.5 5.5 ... NaN \n", "1727 0.0 6.0 ... NaN \n", "1728 0.0 5.5 ... NaN \n", "1729 0.0 6.0 ... NaN \n", "1730 0.5 4.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", "1726 NaN NaN \n", "1727 NaN NaN \n", "1728 NaN NaN \n", "1729 NaN NaN \n", "1730 NaN NaN \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 14.0 48.0 119.0 \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "1726 NaN NaN NaN \n", "1727 NaN NaN NaN \n", "1728 NaN NaN NaN \n", "1729 NaN NaN NaN \n", "1730 NaN NaN NaN \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 25.0 28.0 43.0 4.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", "1726 NaN NaN NaN NaN \n", "1727 NaN NaN NaN NaN \n", "1728 NaN NaN NaN NaN \n", "1729 NaN NaN NaN NaN \n", "1730 NaN NaN NaN NaN \n", "\n", "[1731 rows x 102 columns]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db_gk" ] }, { "cell_type": "code", "execution_count": 26, "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": 27, "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.1000000.2100000.114.00000048.000000119.025.00000028.00000043.0000004.0
161SkorupskiBolognaMilan16.0-200.04.0...4.2000000.2500000.228.00000060.000000159.025.00000034.00000089.0000003.0
291RadunovicCagliariTorino06.5000.06.5...8.7000000.360000-0.333.00000080.000000124.023.00000057.00000087.0000005.0
441CaprileEmpoliVerona15.0-100.04.0...4.9333330.203333-1.48.66666738.66666783.017.66666717.33333336.6666672.0
571TerraccianoFiorentinaGenoa06.0-100.05.0...4.1000000.2400000.128.00000057.000000151.014.00000022.00000044.0000003.0
..................................................................
16576OchoaSalernitanaEmpoli06.5-100.05.5...6.8000000.220000-3.220.00000085.000000160.022.00000047.00000088.0000004.0
16726ConsigliSassuoloInter06.5-100.05.5...4.1000000.210000-1.918.00000069.000000127.014.00000042.00000073.0000004.0
16866Milinkovic-Savic V.TorinoLazio06.0-200.04.0...5.8000000.180000-1.242.000000117.000000193.037.00000050.00000047.0000004.0
17006SilvestriUdineseNapoli05.5-400.01.5...10.1000000.3700000.119.00000050.000000132.023.00000045.00000069.0000001.0
17166Montipo'VeronaAtalanta16.0-100.05.0...6.7000000.2100000.755.000000156.000000183.016.00000050.00000072.0000001.0
\n", "

120 rows × 102 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals \\\n", "0 1 Musso Atalanta Sassuolo 0 6.5 0 \n", "16 1 Skorupski Bologna Milan 1 6.0 -2 \n", "29 1 Radunovic Cagliari Torino 0 6.5 0 \n", "44 1 Caprile Empoli Verona 1 5.0 -1 \n", "57 1 Terracciano Fiorentina Genoa 0 6.0 -1 \n", "... ... ... ... ... ... ... ... \n", "1657 6 Ochoa Salernitana Empoli 0 6.5 -1 \n", "1672 6 Consigli Sassuolo Inter 0 6.5 -1 \n", "1686 6 Milinkovic-Savic V. Torino Lazio 0 6.0 -2 \n", "1700 6 Silvestri Udinese Napoli 0 5.5 -4 \n", "1716 6 Montipo' Verona Atalanta 1 6.0 -1 \n", "\n", " assists cards_malus fantavote ... gk_psxg \\\n", "0 0 0.0 6.5 ... 2.100000 \n", "16 0 0.0 4.0 ... 4.200000 \n", "29 0 0.0 6.5 ... 8.700000 \n", "44 0 0.0 4.0 ... 4.933333 \n", "57 0 0.0 5.0 ... 4.100000 \n", "... ... ... ... ... ... \n", "1657 0 0.0 5.5 ... 6.800000 \n", "1672 0 0.0 5.5 ... 4.100000 \n", "1686 0 0.0 4.0 ... 5.800000 \n", "1700 0 0.0 1.5 ... 10.100000 \n", "1716 0 0.0 5.0 ... 6.700000 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "0 0.210000 0.1 \n", "16 0.250000 0.2 \n", "29 0.360000 -0.3 \n", "44 0.203333 -1.4 \n", "57 0.240000 0.1 \n", "... ... ... \n", "1657 0.220000 -3.2 \n", "1672 0.210000 -1.9 \n", "1686 0.180000 -1.2 \n", "1700 0.370000 0.1 \n", "1716 0.210000 0.7 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "0 14.000000 48.000000 119.0 \n", "16 28.000000 60.000000 159.0 \n", "29 33.000000 80.000000 124.0 \n", "44 8.666667 38.666667 83.0 \n", "57 28.000000 57.000000 151.0 \n", "... ... ... ... \n", "1657 20.000000 85.000000 160.0 \n", "1672 18.000000 69.000000 127.0 \n", "1686 42.000000 117.000000 193.0 \n", "1700 19.000000 50.000000 132.0 \n", "1716 55.000000 156.000000 183.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "0 25.000000 28.000000 43.000000 4.0 \n", "16 25.000000 34.000000 89.000000 3.0 \n", "29 23.000000 57.000000 87.000000 5.0 \n", "44 17.666667 17.333333 36.666667 2.0 \n", "57 14.000000 22.000000 44.000000 3.0 \n", "... ... ... ... ... \n", "1657 22.000000 47.000000 88.000000 4.0 \n", "1672 14.000000 42.000000 73.000000 4.0 \n", "1686 37.000000 50.000000 47.000000 4.0 \n", "1700 23.000000 45.000000 69.000000 1.0 \n", "1716 16.000000 50.000000 72.000000 1.0 \n", "\n", "[120 rows x 102 columns]" ] }, "execution_count": 27, "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": 28, "id": "d8b8b6da", "metadata": {}, "outputs": [], "source": [ "db_gk.to_excel('mid_outputs/database_entries_gk.xlsx')" ] }, { "cell_type": "code", "execution_count": 29, "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 }