{ "cells": [ { "cell_type": "markdown", "id": "b22c6ee8", "metadata": {}, "source": [ "player_match_dataset_creation code for past seasons\n", "\n", "Select the season in season variable, and repeat the code if needed" ] }, { "cell_type": "code", "execution_count": 53, "id": "8a74364d", "metadata": {}, "outputs": [], "source": [ "season = '2021'" ] }, { "cell_type": "code", "execution_count": 54, "id": "8a6867a5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7860\\813865162.py:21: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " team_data['team_idx'][i] = team_data['team_idx'][i].split(' ')[-1]\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
teamteam_players_usedteam_possessionteam_gamesteam_games_startsteam_minutesteam_goalsteam_assiststeam_pens_madeteam_pens_att...vs_team_foulsvs_team_fouledvs_team_offsidesvs_team_pens_wonvs_team_pens_concededvs_team_own_goalsvs_team_ball_recoveriesvs_team_aerials_wonvs_team_aerials_lostvs_team_aerials_won_pct
team_idx
AtalantaAtalanta30.054.638.0418.03420.090.065.06.07.0...504.0548.040.05.07.00.02251.0506.0633.044.4
BeneventoBenevento29.042.638.0418.03420.040.026.05.07.0...621.0463.094.04.07.00.01854.0615.0496.055.4
BolognaBologna37.050.838.0418.03420.049.038.03.04.0...495.0495.071.06.04.02.02024.0594.0564.051.3
CagliariCagliari32.044.838.0418.03420.043.030.04.05.0...507.0496.083.04.05.00.01920.0602.0637.048.6
CrotoneCrotone31.046.338.0418.03420.044.027.09.09.0...524.0499.0103.04.09.01.02130.0534.0472.053.1
FiorentinaFiorentina30.046.338.0418.03420.044.031.06.06.0...545.0500.094.09.06.03.01915.0544.0538.050.3
GenoaGenoa34.044.838.0418.03420.046.032.04.04.0...502.0501.037.07.04.01.02197.0643.0505.056.0
VeronaHellas Verona32.049.838.0418.03420.038.030.03.03.0...557.0593.042.06.03.05.02102.0832.0749.052.6
InterInter25.052.538.0418.03420.084.062.08.09.0...444.0439.032.05.09.05.01690.0428.0439.049.4
JuventusJuventus30.056.938.0418.03420.076.059.08.010.0...490.0483.040.06.010.01.01805.0378.0426.047.0
LazioLazio30.053.038.0418.03420.059.040.06.010.0...454.0480.043.010.010.02.02054.0510.0539.048.6
MilanMilan29.051.738.0418.03420.072.047.015.020.0...502.0486.044.05.020.02.01977.0539.0567.048.7
NapoliNapoli25.055.138.0418.03420.083.056.07.08.0...580.0362.072.05.08.03.01811.0404.0414.049.4
ParmaParma42.047.838.0418.03420.039.026.05.05.0...508.0486.064.03.05.00.01950.0474.0630.042.9
RomaRoma31.052.238.0418.03420.067.051.07.08.0...453.0536.0125.05.08.01.01924.0414.0428.049.2
SampdoriaSampdoria27.045.238.0418.03420.052.037.05.06.0...520.0473.0111.05.06.00.02132.0597.0628.048.7
SassuoloSassuolo28.060.338.0418.03420.061.036.013.014.0...502.0468.091.05.014.03.01843.0450.0408.052.4
SpeziaSpezia35.051.938.0418.03420.052.037.04.05.0...556.0548.0140.07.05.00.01985.0568.0537.051.4
TorinoTorino29.047.338.0418.03420.049.028.05.06.0...632.0544.075.08.06.01.01936.0622.0595.051.1
UdineseUdinese33.046.338.0418.03420.040.030.04.04.0...559.0474.042.09.04.02.01867.0442.0491.047.4
\n", "

20 rows × 303 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 30.0 54.6 38.0 \n", "Benevento Benevento 29.0 42.6 38.0 \n", "Bologna Bologna 37.0 50.8 38.0 \n", "Cagliari Cagliari 32.0 44.8 38.0 \n", "Crotone Crotone 31.0 46.3 38.0 \n", "Fiorentina Fiorentina 30.0 46.3 38.0 \n", "Genoa Genoa 34.0 44.8 38.0 \n", "Verona Hellas Verona 32.0 49.8 38.0 \n", "Inter Inter 25.0 52.5 38.0 \n", "Juventus Juventus 30.0 56.9 38.0 \n", "Lazio Lazio 30.0 53.0 38.0 \n", "Milan Milan 29.0 51.7 38.0 \n", "Napoli Napoli 25.0 55.1 38.0 \n", "Parma Parma 42.0 47.8 38.0 \n", "Roma Roma 31.0 52.2 38.0 \n", "Sampdoria Sampdoria 27.0 45.2 38.0 \n", "Sassuolo Sassuolo 28.0 60.3 38.0 \n", "Spezia Spezia 35.0 51.9 38.0 \n", "Torino Torino 29.0 47.3 38.0 \n", "Udinese Udinese 33.0 46.3 38.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 418.0 3420.0 90.0 65.0 \n", "Benevento 418.0 3420.0 40.0 26.0 \n", "Bologna 418.0 3420.0 49.0 38.0 \n", "Cagliari 418.0 3420.0 43.0 30.0 \n", "Crotone 418.0 3420.0 44.0 27.0 \n", "Fiorentina 418.0 3420.0 44.0 31.0 \n", "Genoa 418.0 3420.0 46.0 32.0 \n", "Verona 418.0 3420.0 38.0 30.0 \n", "Inter 418.0 3420.0 84.0 62.0 \n", "Juventus 418.0 3420.0 76.0 59.0 \n", "Lazio 418.0 3420.0 59.0 40.0 \n", "Milan 418.0 3420.0 72.0 47.0 \n", "Napoli 418.0 3420.0 83.0 56.0 \n", "Parma 418.0 3420.0 39.0 26.0 \n", "Roma 418.0 3420.0 67.0 51.0 \n", "Sampdoria 418.0 3420.0 52.0 37.0 \n", "Sassuolo 418.0 3420.0 61.0 36.0 \n", "Spezia 418.0 3420.0 52.0 37.0 \n", "Torino 418.0 3420.0 49.0 28.0 \n", "Udinese 418.0 3420.0 40.0 30.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls vs_team_fouled \\\n", "team_idx ... \n", "Atalanta 6.0 7.0 ... 504.0 548.0 \n", "Benevento 5.0 7.0 ... 621.0 463.0 \n", "Bologna 3.0 4.0 ... 495.0 495.0 \n", "Cagliari 4.0 5.0 ... 507.0 496.0 \n", "Crotone 9.0 9.0 ... 524.0 499.0 \n", "Fiorentina 6.0 6.0 ... 545.0 500.0 \n", "Genoa 4.0 4.0 ... 502.0 501.0 \n", "Verona 3.0 3.0 ... 557.0 593.0 \n", "Inter 8.0 9.0 ... 444.0 439.0 \n", "Juventus 8.0 10.0 ... 490.0 483.0 \n", "Lazio 6.0 10.0 ... 454.0 480.0 \n", "Milan 15.0 20.0 ... 502.0 486.0 \n", "Napoli 7.0 8.0 ... 580.0 362.0 \n", "Parma 5.0 5.0 ... 508.0 486.0 \n", "Roma 7.0 8.0 ... 453.0 536.0 \n", "Sampdoria 5.0 6.0 ... 520.0 473.0 \n", "Sassuolo 13.0 14.0 ... 502.0 468.0 \n", "Spezia 4.0 5.0 ... 556.0 548.0 \n", "Torino 5.0 6.0 ... 632.0 544.0 \n", "Udinese 4.0 4.0 ... 559.0 474.0 \n", "\n", " vs_team_offsides vs_team_pens_won vs_team_pens_conceded \\\n", "team_idx \n", "Atalanta 40.0 5.0 7.0 \n", "Benevento 94.0 4.0 7.0 \n", "Bologna 71.0 6.0 4.0 \n", "Cagliari 83.0 4.0 5.0 \n", "Crotone 103.0 4.0 9.0 \n", "Fiorentina 94.0 9.0 6.0 \n", "Genoa 37.0 7.0 4.0 \n", "Verona 42.0 6.0 3.0 \n", "Inter 32.0 5.0 9.0 \n", "Juventus 40.0 6.0 10.0 \n", "Lazio 43.0 10.0 10.0 \n", "Milan 44.0 5.0 20.0 \n", "Napoli 72.0 5.0 8.0 \n", "Parma 64.0 3.0 5.0 \n", "Roma 125.0 5.0 8.0 \n", "Sampdoria 111.0 5.0 6.0 \n", "Sassuolo 91.0 5.0 14.0 \n", "Spezia 140.0 7.0 5.0 \n", "Torino 75.0 8.0 6.0 \n", "Udinese 42.0 9.0 4.0 \n", "\n", " vs_team_own_goals vs_team_ball_recoveries vs_team_aerials_won \\\n", "team_idx \n", "Atalanta 0.0 2251.0 506.0 \n", "Benevento 0.0 1854.0 615.0 \n", "Bologna 2.0 2024.0 594.0 \n", "Cagliari 0.0 1920.0 602.0 \n", "Crotone 1.0 2130.0 534.0 \n", "Fiorentina 3.0 1915.0 544.0 \n", "Genoa 1.0 2197.0 643.0 \n", "Verona 5.0 2102.0 832.0 \n", "Inter 5.0 1690.0 428.0 \n", "Juventus 1.0 1805.0 378.0 \n", "Lazio 2.0 2054.0 510.0 \n", "Milan 2.0 1977.0 539.0 \n", "Napoli 3.0 1811.0 404.0 \n", "Parma 0.0 1950.0 474.0 \n", "Roma 1.0 1924.0 414.0 \n", "Sampdoria 0.0 2132.0 597.0 \n", "Sassuolo 3.0 1843.0 450.0 \n", "Spezia 0.0 1985.0 568.0 \n", "Torino 1.0 1936.0 622.0 \n", "Udinese 2.0 1867.0 442.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 633.0 44.4 \n", "Benevento 496.0 55.4 \n", "Bologna 564.0 51.3 \n", "Cagliari 637.0 48.6 \n", "Crotone 472.0 53.1 \n", "Fiorentina 538.0 50.3 \n", "Genoa 505.0 56.0 \n", "Verona 749.0 52.6 \n", "Inter 439.0 49.4 \n", "Juventus 426.0 47.0 \n", "Lazio 539.0 48.6 \n", "Milan 567.0 48.7 \n", "Napoli 414.0 49.4 \n", "Parma 630.0 42.9 \n", "Roma 428.0 49.2 \n", "Sampdoria 628.0 48.7 \n", "Sassuolo 408.0 52.4 \n", "Spezia 537.0 51.4 \n", "Torino 595.0 51.1 \n", "Udinese 491.0 47.4 \n", "\n", "[20 rows x 303 columns]" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "rcsv = pd.read_csv('fbref_data/season' + season + '/teams.csv') \n", "team = pd.DataFrame(rcsv)\n", "\n", "rcsv = pd.read_csv('fbref_data/season' + season + '/teams_vs.csv') \n", "vs_team = pd.DataFrame(rcsv)\n", "\n", "for i in range(1, team.shape[1]):\n", " team = team.rename(columns = {team.columns[i] : 'team_' + team.columns[i]})\n", " \n", "for i in range(1, vs_team.shape[1]):\n", " vs_team = vs_team.rename(columns = {vs_team.columns[i] : 'vs_team_' + vs_team.columns[i]})\n", " \n", "vs_team.pop('team')\n", "\n", "team_data = pd.concat([team, vs_team], axis = 1)\n", "\n", "team_data['team_idx'] = team_data['team']\n", "for i in range(team_data.shape[0]):\n", " team_data['team_idx'][i] = team_data['team_idx'][i].split(' ')[-1]\n", "\n", "team_data = team_data.set_index('team_idx')\n", "\n", "team_data\n", "\n" ] }, { "cell_type": "code", "execution_count": 55, "id": "b6a3db98", "metadata": {}, "outputs": [], "source": [ "team_data.to_excel('mid_outputs/season' + season + '/team_data.xlsx')" ] }, { "cell_type": "code", "execution_count": 56, "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
Donnarumma G.0350PMilanDonnarummaG6292119990...41.533.7556.029.05.243.01.1614.86.2837840.394909
Szczesny1453PJuventusSzczesnyNaN6643019900...10.622.0399.012.03.037.01.2416.26.2166670.441273
Handanovic2250PInterHandanovicNaN6353619840...26.930.8441.013.02.922.00.6114.96.0270270.505990
Gollini3610PAtalantaGolliniNaN6342519950...63.849.7234.06.02.639.01.6317.46.1000000.632456
Audero4761PSampdoriaAuderoNaN6202319970...64.145.3563.012.02.134.00.9214.86.3783780.409439
..................................................................
Rabbi5595361ABolognaRabbiNaN4641820014...0.00.00.00.00.00.00.000.06.1122160.535288
Oddei5605378ASassuoloOddeiNaN4001720025...0.00.00.00.00.00.00.000.06.1530910.381442
Karamoko Is.5615414ASassuoloKaramokoI2671820021...0.00.00.00.00.00.00.000.06.0425600.412530
Correia5625419AJuventusCorreiaNaN1131920011...0.00.00.00.00.00.00.000.06.2865960.267071
Raimondo5635436ABolognaRaimondoNaN4701620041...0.00.00.00.00.00.00.000.06.3635720.428066
\n", "

564 rows × 160 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "name \n", "Donnarumma G. 0 350 P Milan Donnarumma G 629 21 \n", "Szczesny 1 453 P Juventus Szczesny NaN 664 30 \n", "Handanovic 2 250 P Inter Handanovic NaN 635 36 \n", "Gollini 3 610 P Atalanta Gollini NaN 634 25 \n", "Audero 4 761 P Sampdoria Audero NaN 620 23 \n", "... ... ... .. ... ... ... ... ... \n", "Rabbi 559 5361 A Bologna Rabbi NaN 464 18 \n", "Oddei 560 5378 A Sassuolo Oddei NaN 400 17 \n", "Karamoko Is. 561 5414 A Sassuolo Karamoko I 267 18 \n", "Correia 562 5419 A Juventus Correia NaN 113 19 \n", "Raimondo 563 5436 A Bologna Raimondo NaN 470 16 \n", "\n", " birth_year games ... gk_pct_goal_kicks_launched \\\n", "name ... \n", "Donnarumma G. 1999 0 ... 41.5 \n", "Szczesny 1990 0 ... 10.6 \n", "Handanovic 1984 0 ... 26.9 \n", "Gollini 1995 0 ... 63.8 \n", "Audero 1997 0 ... 64.1 \n", "... ... ... ... ... \n", "Rabbi 2001 4 ... 0.0 \n", "Oddei 2002 5 ... 0.0 \n", "Karamoko Is. 2002 1 ... 0.0 \n", "Correia 2001 1 ... 0.0 \n", "Raimondo 2004 1 ... 0.0 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "name \n", "Donnarumma G. 33.7 556.0 29.0 \n", "Szczesny 22.0 399.0 12.0 \n", "Handanovic 30.8 441.0 13.0 \n", "Gollini 49.7 234.0 6.0 \n", "Audero 45.3 563.0 12.0 \n", "... ... ... ... \n", "Rabbi 0.0 0.0 0.0 \n", "Oddei 0.0 0.0 0.0 \n", "Karamoko Is. 0.0 0.0 0.0 \n", "Correia 0.0 0.0 0.0 \n", "Raimondo 0.0 0.0 0.0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "name \n", "Donnarumma G. 5.2 43.0 \n", "Szczesny 3.0 37.0 \n", "Handanovic 2.9 22.0 \n", "Gollini 2.6 39.0 \n", "Audero 2.1 34.0 \n", "... ... ... \n", "Rabbi 0.0 0.0 \n", "Oddei 0.0 0.0 \n", "Karamoko Is. 0.0 0.0 \n", "Correia 0.0 0.0 \n", "Raimondo 0.0 0.0 \n", "\n", " gk_def_actions_outside_pen_area_per90 \\\n", "name \n", "Donnarumma G. 1.16 \n", "Szczesny 1.24 \n", "Handanovic 0.61 \n", "Gollini 1.63 \n", "Audero 0.92 \n", "... ... \n", "Rabbi 0.00 \n", "Oddei 0.00 \n", "Karamoko Is. 0.00 \n", "Correia 0.00 \n", "Raimondo 0.00 \n", "\n", " gk_avg_distance_def_actions vote_avg vote_std \n", "name \n", "Donnarumma G. 14.8 6.283784 0.394909 \n", "Szczesny 16.2 6.216667 0.441273 \n", "Handanovic 14.9 6.027027 0.505990 \n", "Gollini 17.4 6.100000 0.632456 \n", "Audero 14.8 6.378378 0.409439 \n", "... ... ... ... \n", "Rabbi 0.0 6.112216 0.535288 \n", "Oddei 0.0 6.153091 0.381442 \n", "Karamoko Is. 0.0 6.042560 0.412530 \n", "Correia 0.0 6.286596 0.267071 \n", "Raimondo 0.0 6.363572 0.428066 \n", "\n", "[564 rows x 160 columns]" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rx = pd.read_excel('mid_outputs/season' + season + '/players_stats.xlsx', index_col = 3) \n", "players = pd.DataFrame(rx)\n", "\n", "players\n" ] }, { "cell_type": "code", "execution_count": 57, "id": "f9f7f88c", "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": "code", "execution_count": 58, "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
Immobile452785ALazioImmobileNaN25030199035...504.0548.040.05.07.00.02251.0506.0633.044.4
\n", "

1 rows × 766 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age birth_year \\\n", "Immobile 452 785 A Lazio Immobile NaN 250 30 1990 \n", "\n", " games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Immobile 35 ... 504.0 548.0 \n", "\n", " opp_vs_team_offsides opp_vs_team_pens_won \\\n", "Immobile 40.0 5.0 \n", "\n", " opp_vs_team_pens_conceded opp_vs_team_own_goals \\\n", "Immobile 7.0 0.0 \n", "\n", " opp_vs_team_ball_recoveries opp_vs_team_aerials_won \\\n", "Immobile 2251.0 506.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Immobile 633.0 44.4 \n", "\n", "[1 rows x 766 columns]" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data('Immobile', 'Lazio', 'Atalanta')\n", "test.to_excel('tmp/playermatchdata.xlsx')\n", "\n", "test" ] }, { "cell_type": "code", "execution_count": 59, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Lazio'" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pteam = 'Lazio'\n", "pteam_stats = team_data.loc[[pteam]]\n", "pteam_stats.index[0]" ] }, { "cell_type": "code", "execution_count": 60, "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": 60, "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": "code", "execution_count": 61, "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": "code", "execution_count": 62, "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": "code", "execution_count": 63, "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
ImmobileA3534284939.30.140.3672.632.553.0...0.0249210.0119340.0129870.0154440.0091260.0189540.24570.0259740.0150930.013338
\n", "

1 rows × 112 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct \\\n", "Immobile A 35 34 2849 39.3 \n", "\n", " goals_per_shot goals_per_shot_on_target passes_pct \\\n", "Immobile 0.14 0.36 72.6 \n", "\n", " aerials_won_pct team_possession ... miscontrols dispossessed \\\n", "Immobile 32.5 53.0 ... 0.024921 0.011934 \n", "\n", " fouls fouled aerials_won aerials_lost carries \\\n", "Immobile 0.012987 0.015444 0.009126 0.018954 0.2457 \n", "\n", " progressive_carries carries_into_final_third \\\n", "Immobile 0.025974 0.015093 \n", "\n", " carries_into_penalty_area \n", "Immobile 0.013338 \n", "\n", "[1 rows x 112 columns]" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test = player_match_data_ext('Immobile', 'Lazio', 'Atalanta')\n", "\n", "add_columns = test.columns\n", "\n", "test" ] }, { "cell_type": "code", "execution_count": 64, "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
01SportielloAtalantaLazio06.5-100.05.5
11ToloiAtalantaLazio06.0000.55.5
21DjimsitiAtalantaLazio06.5000.56.0
31HateboerAtalantaLazio07.5100.010.5
41GosensAtalantaLazio07.5110.011.5
.................................
1056938BessaVeronaNapoli06.0000.06.0
1057038ZaccagniVeronaNapoli06.5000.06.5
1057138IlicVeronaNapoli06.5000.56.0
1057238LasagnaVeronaNapoli05.5000.05.5
1057338KalinicVeronaNapoli05.5000.05.5
\n", "

10574 rows × 10 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Sportiello Atalanta Lazio 0 6.5 -1 0 \n", "1 1 Toloi Atalanta Lazio 0 6.0 0 0 \n", "2 1 Djimsiti Atalanta Lazio 0 6.5 0 0 \n", "3 1 Hateboer Atalanta Lazio 0 7.5 1 0 \n", "4 1 Gosens Atalanta Lazio 0 7.5 1 1 \n", "... ... ... ... ... ... ... ... ... \n", "10569 38 Bessa Verona Napoli 0 6.0 0 0 \n", "10570 38 Zaccagni Verona Napoli 0 6.5 0 0 \n", "10571 38 Ilic Verona Napoli 0 6.5 0 0 \n", "10572 38 Lasagna Verona Napoli 0 5.5 0 0 \n", "10573 38 Kalinic Verona Napoli 0 5.5 0 0 \n", "\n", " cards_malus fantavote \n", "0 0.0 5.5 \n", "1 0.5 5.5 \n", "2 0.5 6.0 \n", "3 0.0 10.5 \n", "4 0.0 11.5 \n", "... ... ... \n", "10569 0.0 6.0 \n", "10570 0.0 6.5 \n", "10571 0.5 6.0 \n", "10572 0.0 5.5 \n", "10573 0.0 5.5 \n", "\n", "[10574 rows x 10 columns]" ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "votes = pd.read_excel('mid_outputs/season' + season + '/players_votes.xlsx', index_col = 0)\n", "votes" ] }, { "cell_type": "code", "execution_count": 65, "id": "ec0bc56b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "100\n", "200\n", "300\n", "400\n", "500\n", "700\n", "800\n", "900\n", "1000\n", "1100\n", "1300\n", "1400\n", "1500\n", "1600\n", "1700\n", "1800\n", "1900\n", "2000\n", "2100\n", "2200\n", "2300\n", "2400\n", "2500\n", "2600\n", "2700\n", "2800\n", "2900\n", "3000\n", "3100\n", "3200\n", "3300\n", "3400\n", "3500\n", "3600\n", "3700\n", "3800\n", "3900\n", "4000\n", "4100\n", "4200\n", "4300\n", "4400\n", "4500\n", "4600\n", "4700\n", "4800\n", "5000\n", "5100\n", "5200\n", "5300\n", "5400\n", "5500\n", "5600\n", "5700\n", "5800\n", "5900\n", "6000\n", "6100\n", "6200\n", "6300\n", "6400\n", "6500\n", "6600\n", "6700\n", "6800\n", "6900\n", "7000\n", "7100\n", "7200\n", "7300\n", "7400\n", "7500\n", "7600\n", "7700\n", "7800\n", "7900\n", "8000\n", "8100\n", "8200\n", "8300\n", "8400\n", "8500\n", "8600\n", "8700\n", "8800\n", "8900\n", "9000\n", "9100\n", "9200\n", "9300\n", "9400\n", "9500\n", "9600\n", "9700\n", "9800\n", "9900\n", "10000\n", "10100\n", "10200\n", "10300\n", "10400\n", "10500\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": 66, "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
01SportielloAtalantaLazio06.5-100.05.5...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
11ToloiAtalantaLazio06.0000.55.5...0.0086720.0051240.0149780.0059120.0181320.0110370.4304300.0157670.0141900.001182
21DjimsitiAtalantaLazio06.5000.56.0...0.0095240.0034290.0118100.0099050.0289520.0118100.4605710.0160000.0198100.001905
31HateboerAtalantaLazio07.5100.010.5...0.0158910.0068100.0113510.0045400.0130530.0113510.3864930.0232690.0170260.003973
41GosensAtalantaLazio07.5110.011.5...0.0162500.0063420.0198180.0103050.0142690.0079270.4177570.0281410.0225920.006342
..................................................................
1056938BessaVeronaNapoli06.0000.06.0...0.0292680.0195120.0260160.0097560.0032520.0260160.4016260.0308940.0308940.006504
1057038ZaccagniVeronaNapoli06.5000.06.5...0.0283630.0245300.0137980.0417780.0180150.0218470.3296280.0452280.0264470.017631
1057138IlicVeronaNapoli06.5000.56.0...0.0141690.0070840.0125340.0158040.0190740.0136240.4070840.0207080.0158040.000545
1057238LasagnaVeronaNapoli05.5000.05.5...0.0402530.0142070.0252570.0165750.0205210.0378850.1838990.0220990.0142070.013418
1057338KalinicVeronaNapoli05.5000.05.5...0.0329260.0122300.0254000.0319850.0159920.0479770.1994360.0065850.0047040.002822
\n", "

10574 rows × 122 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Sportiello Atalanta Lazio 0 6.5 -1 0 \n", "1 1 Toloi Atalanta Lazio 0 6.0 0 0 \n", "2 1 Djimsiti Atalanta Lazio 0 6.5 0 0 \n", "3 1 Hateboer Atalanta Lazio 0 7.5 1 0 \n", "4 1 Gosens Atalanta Lazio 0 7.5 1 1 \n", "... ... ... ... ... ... ... ... ... \n", "10569 38 Bessa Verona Napoli 0 6.0 0 0 \n", "10570 38 Zaccagni Verona Napoli 0 6.5 0 0 \n", "10571 38 Ilic Verona Napoli 0 6.5 0 0 \n", "10572 38 Lasagna Verona Napoli 0 5.5 0 0 \n", "10573 38 Kalinic Verona Napoli 0 5.5 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "0 0.0 5.5 ... 0.000000 0.000000 0.000000 \n", "1 0.5 5.5 ... 0.008672 0.005124 0.014978 \n", "2 0.5 6.0 ... 0.009524 0.003429 0.011810 \n", "3 0.0 10.5 ... 0.015891 0.006810 0.011351 \n", "4 0.0 11.5 ... 0.016250 0.006342 0.019818 \n", "... ... ... ... ... ... ... \n", "10569 0.0 6.0 ... 0.029268 0.019512 0.026016 \n", "10570 0.0 6.5 ... 0.028363 0.024530 0.013798 \n", "10571 0.5 6.0 ... 0.014169 0.007084 0.012534 \n", "10572 0.0 5.5 ... 0.040253 0.014207 0.025257 \n", "10573 0.0 5.5 ... 0.032926 0.012230 0.025400 \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.005912 0.018132 0.011037 0.430430 0.015767 \n", "2 0.009905 0.028952 0.011810 0.460571 0.016000 \n", "3 0.004540 0.013053 0.011351 0.386493 0.023269 \n", "4 0.010305 0.014269 0.007927 0.417757 0.028141 \n", "... ... ... ... ... ... \n", "10569 0.009756 0.003252 0.026016 0.401626 0.030894 \n", "10570 0.041778 0.018015 0.021847 0.329628 0.045228 \n", "10571 0.015804 0.019074 0.013624 0.407084 0.020708 \n", "10572 0.016575 0.020521 0.037885 0.183899 0.022099 \n", "10573 0.031985 0.015992 0.047977 0.199436 0.006585 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "0 0.000000 0.000000 \n", "1 0.014190 0.001182 \n", "2 0.019810 0.001905 \n", "3 0.017026 0.003973 \n", "4 0.022592 0.006342 \n", "... ... ... \n", "10569 0.030894 0.006504 \n", "10570 0.026447 0.017631 \n", "10571 0.015804 0.000545 \n", "10572 0.014207 0.013418 \n", "10573 0.004704 0.002822 \n", "\n", "[10574 rows x 122 columns]" ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "code", "execution_count": 67, "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 extisting players\n", "db = db.drop(db[db.r != db.r].index) # remove non extisting players\n", "db = db.drop(db[db.xg != db.xg].index) \n" ] }, { "cell_type": "code", "execution_count": 68, "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
11ToloiAtalantaLazio06.0000.55.5...0.0086720.0051240.0149780.0059120.0181320.0110370.4304300.0157670.0141900.001182
21DjimsitiAtalantaLazio06.5000.56.0...0.0095240.0034290.0118100.0099050.0289520.0118100.4605710.0160000.0198100.001905
31HateboerAtalantaLazio07.5100.010.5...0.0158910.0068100.0113510.0045400.0130530.0113510.3864930.0232690.0170260.003973
41GosensAtalantaLazio07.5110.011.5...0.0162500.0063420.0198180.0103050.0142690.0079270.4177570.0281410.0225920.006342
51PalominoAtalantaLazio06.5000.06.5...0.0053540.0020590.0197690.0065900.0243000.0185340.4044480.0065900.0049420.000824
..................................................................
1056938BessaVeronaNapoli06.0000.06.0...0.0292680.0195120.0260160.0097560.0032520.0260160.4016260.0308940.0308940.006504
1057038ZaccagniVeronaNapoli06.5000.06.5...0.0283630.0245300.0137980.0417780.0180150.0218470.3296280.0452280.0264470.017631
1057138IlicVeronaNapoli06.5000.56.0...0.0141690.0070840.0125340.0158040.0190740.0136240.4070840.0207080.0158040.000545
1057238LasagnaVeronaNapoli05.5000.05.5...0.0402530.0142070.0252570.0165750.0205210.0378850.1838990.0220990.0142070.013418
1057338KalinicVeronaNapoli05.5000.05.5...0.0329260.0122300.0254000.0319850.0159920.0479770.1994360.0065850.0047040.002822
\n", "

9663 rows × 122 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "1 1 Toloi Atalanta Lazio 0 6.0 0 0 \n", "2 1 Djimsiti Atalanta Lazio 0 6.5 0 0 \n", "3 1 Hateboer Atalanta Lazio 0 7.5 1 0 \n", "4 1 Gosens Atalanta Lazio 0 7.5 1 1 \n", "5 1 Palomino Atalanta Lazio 0 6.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "10569 38 Bessa Verona Napoli 0 6.0 0 0 \n", "10570 38 Zaccagni Verona Napoli 0 6.5 0 0 \n", "10571 38 Ilic Verona Napoli 0 6.5 0 0 \n", "10572 38 Lasagna Verona Napoli 0 5.5 0 0 \n", "10573 38 Kalinic Verona Napoli 0 5.5 0 0 \n", "\n", " cards_malus fantavote ... miscontrols dispossessed fouls \\\n", "1 0.5 5.5 ... 0.008672 0.005124 0.014978 \n", "2 0.5 6.0 ... 0.009524 0.003429 0.011810 \n", "3 0.0 10.5 ... 0.015891 0.006810 0.011351 \n", "4 0.0 11.5 ... 0.016250 0.006342 0.019818 \n", "5 0.0 6.5 ... 0.005354 0.002059 0.019769 \n", "... ... ... ... ... ... ... \n", "10569 0.0 6.0 ... 0.029268 0.019512 0.026016 \n", "10570 0.0 6.5 ... 0.028363 0.024530 0.013798 \n", "10571 0.5 6.0 ... 0.014169 0.007084 0.012534 \n", "10572 0.0 5.5 ... 0.040253 0.014207 0.025257 \n", "10573 0.0 5.5 ... 0.032926 0.012230 0.025400 \n", "\n", " fouled aerials_won aerials_lost carries progressive_carries \\\n", "1 0.005912 0.018132 0.011037 0.430430 0.015767 \n", "2 0.009905 0.028952 0.011810 0.460571 0.016000 \n", "3 0.004540 0.013053 0.011351 0.386493 0.023269 \n", "4 0.010305 0.014269 0.007927 0.417757 0.028141 \n", "5 0.006590 0.024300 0.018534 0.404448 0.006590 \n", "... ... ... ... ... ... \n", "10569 0.009756 0.003252 0.026016 0.401626 0.030894 \n", "10570 0.041778 0.018015 0.021847 0.329628 0.045228 \n", "10571 0.015804 0.019074 0.013624 0.407084 0.020708 \n", "10572 0.016575 0.020521 0.037885 0.183899 0.022099 \n", "10573 0.031985 0.015992 0.047977 0.199436 0.006585 \n", "\n", " carries_into_final_third carries_into_penalty_area \n", "1 0.014190 0.001182 \n", "2 0.019810 0.001905 \n", "3 0.017026 0.003973 \n", "4 0.022592 0.006342 \n", "5 0.004942 0.000824 \n", "... ... ... \n", "10569 0.030894 0.006504 \n", "10570 0.026447 0.017631 \n", "10571 0.015804 0.000545 \n", "10572 0.014207 0.013418 \n", "10573 0.004704 0.002822 \n", "\n", "[9663 rows x 122 columns]" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "code", "execution_count": 69, "id": "df26c8e0", "metadata": {}, "outputs": [], "source": [ "db.to_excel('mid_outputs/season' + season + '/database_entries.xlsx')" ] }, { "cell_type": "markdown", "id": "626ba83b", "metadata": {}, "source": [ "Goalkeepers" ] }, { "cell_type": "code", "execution_count": 70, "id": "ba7b838c", "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": 71, "id": "1d2682b9", "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": 72, "id": "bc6e9d52", "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
Consigli373733301.5171.918.9-0.0437.024.027.7...53.60.27-1.4118.0319.01114.0172.0240.0513.026.0
\n", "

1 rows × 92 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 37 37 3330 1.51 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 71.9 18.9 -0.04 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 37.0 24.0 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 27.7 ... 53.6 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.27 -1.4 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 118.0 319.0 1114.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 172.0 240.0 513.0 26.0 \n", "\n", "[1 rows x 92 columns]" ] }, "execution_count": 72, "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": 73, "id": "6f08e718", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "100\n", "200\n", "300\n", "400\n", "500\n", "600\n", "700\n", "800\n", "900\n", "1000\n", "1100\n", "1200\n", "1300\n", "1400\n", "1500\n", "1600\n", "1700\n", "1800\n", "1900\n", "2000\n", "2100\n", "2200\n", "2300\n", "2400\n", "2500\n", "2600\n", "2700\n", "2800\n", "2900\n", "3000\n", "3100\n", "3200\n", "3300\n", "3400\n", "3500\n", "3600\n", "3700\n", "3800\n", "3900\n", "4000\n", "4100\n", "4200\n", "4300\n", "4400\n", "4500\n", "4600\n", "4700\n", "4800\n", "4900\n", "5000\n", "5100\n", "5200\n", "5300\n", "5400\n", "5500\n", "5600\n", "5700\n", "5800\n", "5900\n", "6000\n", "6100\n", "6200\n", "6300\n", "6400\n", "6500\n", "6600\n", "6700\n", "6800\n", "6900\n", "7000\n", "7100\n", "7200\n", "7300\n", "7400\n", "7500\n", "7600\n", "7700\n", "7800\n", "7900\n", "8000\n", "8100\n", "8200\n", "8300\n", "8400\n", "8500\n", "8600\n", "8700\n", "8800\n", "8900\n", "9000\n", "9100\n", "9200\n", "9300\n", "9400\n", "9500\n", "9600\n", "9700\n", "9800\n", "9900\n", "10000\n", "10100\n", "10200\n", "10300\n", "10400\n", "10500\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": 74, "id": "2b540670", "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": 75, "id": "35495581", "metadata": {}, "outputs": [], "source": [ "db_gk.to_excel('mid_outputs/season' + season + '/database_entries_gk.xlsx')" ] }, { "cell_type": "code", "execution_count": null, "id": "43b85925", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }