{ "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": 44, "id": "8a74364d", "metadata": {}, "outputs": [], "source": [ "season = '2122'" ] }, { "cell_type": "code", "execution_count": 45, "id": "8a6867a5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_1244\\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
AtalantaAtalanta32.055.038.0418.03420.062.048.05.06.0...491.0488.069.04.06.03.02240.0518.0685.043.1
BolognaBologna36.050.638.0418.03420.043.034.04.05.0...527.0416.088.08.05.01.02032.0520.0492.051.4
CagliariCagliari33.044.538.0418.03420.034.026.03.04.0...526.0524.076.06.04.00.02112.0742.0696.051.6
EmpoliEmpoli28.047.438.0418.03420.047.027.07.07.0...488.0482.066.07.07.03.02051.0549.0427.056.3
FiorentinaFiorentina28.057.738.0418.03420.059.033.09.012.0...585.0441.0119.04.012.00.01825.0456.0469.049.3
GenoaGenoa40.043.938.0418.03420.026.019.06.07.0...523.0530.059.04.07.01.02257.0743.0635.053.9
VeronaHellas Verona31.050.638.0418.03420.063.044.07.08.0...463.0534.032.03.08.02.02206.0733.0689.051.5
InterInter27.056.538.0418.03420.083.057.07.011.0...440.0441.034.03.011.01.01767.0476.0549.046.4
JuventusJuventus32.051.538.0418.03420.056.037.05.06.0...525.0471.035.05.06.01.01894.0440.0550.044.4
LazioLazio27.055.438.0418.03420.074.048.07.09.0...474.0418.073.06.09.03.01956.0427.0411.051.0
MilanMilan28.054.038.0418.03420.066.039.05.08.0...533.0440.063.03.08.03.02106.0517.0521.049.8
NapoliNapoli27.058.338.0418.03420.074.046.010.014.0...517.0415.060.00.014.00.01963.0403.0393.050.6
RomaRoma29.051.438.0418.03420.058.031.07.09.0...497.0477.081.05.09.01.01970.0441.0524.045.7
SalernitanaSalernitana42.041.238.0418.03420.032.019.04.05.0...546.0463.063.06.05.01.02043.0506.0657.043.5
SampdoriaSampdoria34.046.138.0418.03420.042.029.02.04.0...538.0471.064.01.04.04.02174.0506.0609.045.4
SassuoloSassuolo29.054.938.0418.03420.060.039.07.07.0...519.0434.0142.06.07.04.02041.0404.0343.054.1
SpeziaSpezia30.042.738.0418.03420.038.025.03.05.0...474.0477.062.08.05.03.02064.0589.0530.052.6
TorinoTorino31.053.338.0418.03420.043.027.06.06.0...485.0611.060.010.06.03.01989.0891.0781.053.3
UdineseUdinese29.042.738.0418.03420.058.036.03.04.0...494.0537.057.06.04.03.02010.0534.0453.054.1
VeneziaVenezia39.042.338.0418.03420.034.023.03.05.0...476.0492.048.05.05.00.02059.0583.0564.050.8
\n", "

20 rows × 313 columns

\n", "
" ], "text/plain": [ " team team_players_used team_possession team_games \\\n", "team_idx \n", "Atalanta Atalanta 32.0 55.0 38.0 \n", "Bologna Bologna 36.0 50.6 38.0 \n", "Cagliari Cagliari 33.0 44.5 38.0 \n", "Empoli Empoli 28.0 47.4 38.0 \n", "Fiorentina Fiorentina 28.0 57.7 38.0 \n", "Genoa Genoa 40.0 43.9 38.0 \n", "Verona Hellas Verona 31.0 50.6 38.0 \n", "Inter Inter 27.0 56.5 38.0 \n", "Juventus Juventus 32.0 51.5 38.0 \n", "Lazio Lazio 27.0 55.4 38.0 \n", "Milan Milan 28.0 54.0 38.0 \n", "Napoli Napoli 27.0 58.3 38.0 \n", "Roma Roma 29.0 51.4 38.0 \n", "Salernitana Salernitana 42.0 41.2 38.0 \n", "Sampdoria Sampdoria 34.0 46.1 38.0 \n", "Sassuolo Sassuolo 29.0 54.9 38.0 \n", "Spezia Spezia 30.0 42.7 38.0 \n", "Torino Torino 31.0 53.3 38.0 \n", "Udinese Udinese 29.0 42.7 38.0 \n", "Venezia Venezia 39.0 42.3 38.0 \n", "\n", " team_games_starts team_minutes team_goals team_assists \\\n", "team_idx \n", "Atalanta 418.0 3420.0 62.0 48.0 \n", "Bologna 418.0 3420.0 43.0 34.0 \n", "Cagliari 418.0 3420.0 34.0 26.0 \n", "Empoli 418.0 3420.0 47.0 27.0 \n", "Fiorentina 418.0 3420.0 59.0 33.0 \n", "Genoa 418.0 3420.0 26.0 19.0 \n", "Verona 418.0 3420.0 63.0 44.0 \n", "Inter 418.0 3420.0 83.0 57.0 \n", "Juventus 418.0 3420.0 56.0 37.0 \n", "Lazio 418.0 3420.0 74.0 48.0 \n", "Milan 418.0 3420.0 66.0 39.0 \n", "Napoli 418.0 3420.0 74.0 46.0 \n", "Roma 418.0 3420.0 58.0 31.0 \n", "Salernitana 418.0 3420.0 32.0 19.0 \n", "Sampdoria 418.0 3420.0 42.0 29.0 \n", "Sassuolo 418.0 3420.0 60.0 39.0 \n", "Spezia 418.0 3420.0 38.0 25.0 \n", "Torino 418.0 3420.0 43.0 27.0 \n", "Udinese 418.0 3420.0 58.0 36.0 \n", "Venezia 418.0 3420.0 34.0 23.0 \n", "\n", " team_pens_made team_pens_att ... vs_team_fouls \\\n", "team_idx ... \n", "Atalanta 5.0 6.0 ... 491.0 \n", "Bologna 4.0 5.0 ... 527.0 \n", "Cagliari 3.0 4.0 ... 526.0 \n", "Empoli 7.0 7.0 ... 488.0 \n", "Fiorentina 9.0 12.0 ... 585.0 \n", "Genoa 6.0 7.0 ... 523.0 \n", "Verona 7.0 8.0 ... 463.0 \n", "Inter 7.0 11.0 ... 440.0 \n", "Juventus 5.0 6.0 ... 525.0 \n", "Lazio 7.0 9.0 ... 474.0 \n", "Milan 5.0 8.0 ... 533.0 \n", "Napoli 10.0 14.0 ... 517.0 \n", "Roma 7.0 9.0 ... 497.0 \n", "Salernitana 4.0 5.0 ... 546.0 \n", "Sampdoria 2.0 4.0 ... 538.0 \n", "Sassuolo 7.0 7.0 ... 519.0 \n", "Spezia 3.0 5.0 ... 474.0 \n", "Torino 6.0 6.0 ... 485.0 \n", "Udinese 3.0 4.0 ... 494.0 \n", "Venezia 3.0 5.0 ... 476.0 \n", "\n", " vs_team_fouled vs_team_offsides vs_team_pens_won \\\n", "team_idx \n", "Atalanta 488.0 69.0 4.0 \n", "Bologna 416.0 88.0 8.0 \n", "Cagliari 524.0 76.0 6.0 \n", "Empoli 482.0 66.0 7.0 \n", "Fiorentina 441.0 119.0 4.0 \n", "Genoa 530.0 59.0 4.0 \n", "Verona 534.0 32.0 3.0 \n", "Inter 441.0 34.0 3.0 \n", "Juventus 471.0 35.0 5.0 \n", "Lazio 418.0 73.0 6.0 \n", "Milan 440.0 63.0 3.0 \n", "Napoli 415.0 60.0 0.0 \n", "Roma 477.0 81.0 5.0 \n", "Salernitana 463.0 63.0 6.0 \n", "Sampdoria 471.0 64.0 1.0 \n", "Sassuolo 434.0 142.0 6.0 \n", "Spezia 477.0 62.0 8.0 \n", "Torino 611.0 60.0 10.0 \n", "Udinese 537.0 57.0 6.0 \n", "Venezia 492.0 48.0 5.0 \n", "\n", " vs_team_pens_conceded vs_team_own_goals \\\n", "team_idx \n", "Atalanta 6.0 3.0 \n", "Bologna 5.0 1.0 \n", "Cagliari 4.0 0.0 \n", "Empoli 7.0 3.0 \n", "Fiorentina 12.0 0.0 \n", "Genoa 7.0 1.0 \n", "Verona 8.0 2.0 \n", "Inter 11.0 1.0 \n", "Juventus 6.0 1.0 \n", "Lazio 9.0 3.0 \n", "Milan 8.0 3.0 \n", "Napoli 14.0 0.0 \n", "Roma 9.0 1.0 \n", "Salernitana 5.0 1.0 \n", "Sampdoria 4.0 4.0 \n", "Sassuolo 7.0 4.0 \n", "Spezia 5.0 3.0 \n", "Torino 6.0 3.0 \n", "Udinese 4.0 3.0 \n", "Venezia 5.0 0.0 \n", "\n", " vs_team_ball_recoveries vs_team_aerials_won \\\n", "team_idx \n", "Atalanta 2240.0 518.0 \n", "Bologna 2032.0 520.0 \n", "Cagliari 2112.0 742.0 \n", "Empoli 2051.0 549.0 \n", "Fiorentina 1825.0 456.0 \n", "Genoa 2257.0 743.0 \n", "Verona 2206.0 733.0 \n", "Inter 1767.0 476.0 \n", "Juventus 1894.0 440.0 \n", "Lazio 1956.0 427.0 \n", "Milan 2106.0 517.0 \n", "Napoli 1963.0 403.0 \n", "Roma 1970.0 441.0 \n", "Salernitana 2043.0 506.0 \n", "Sampdoria 2174.0 506.0 \n", "Sassuolo 2041.0 404.0 \n", "Spezia 2064.0 589.0 \n", "Torino 1989.0 891.0 \n", "Udinese 2010.0 534.0 \n", "Venezia 2059.0 583.0 \n", "\n", " vs_team_aerials_lost vs_team_aerials_won_pct \n", "team_idx \n", "Atalanta 685.0 43.1 \n", "Bologna 492.0 51.4 \n", "Cagliari 696.0 51.6 \n", "Empoli 427.0 56.3 \n", "Fiorentina 469.0 49.3 \n", "Genoa 635.0 53.9 \n", "Verona 689.0 51.5 \n", "Inter 549.0 46.4 \n", "Juventus 550.0 44.4 \n", "Lazio 411.0 51.0 \n", "Milan 521.0 49.8 \n", "Napoli 393.0 50.6 \n", "Roma 524.0 45.7 \n", "Salernitana 657.0 43.5 \n", "Sampdoria 609.0 45.4 \n", "Sassuolo 343.0 54.1 \n", "Spezia 530.0 52.6 \n", "Torino 781.0 53.3 \n", "Udinese 453.0 54.1 \n", "Venezia 564.0 50.8 \n", "\n", "[20 rows x 313 columns]" ] }, "execution_count": 45, "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": 46, "id": "b6a3db98", "metadata": {}, "outputs": [], "source": [ "team_data.to_excel('mid_outputs/season' + season + '/team_data.xlsx')" ] }, { "cell_type": "code", "execution_count": 47, "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
Maignan04312PMilanMaignanNaN6472619950...38.936.5347.025.07.245.01.4116.86.2656250.483871
Szczesny1453PJuventusSzczesnyNaN6753119900...29.731.5481.024.05.025.00.7613.56.1212120.628012
Ospina22468PNapoliOspinaNaN6533219880...14.122.5353.018.05.131.01.0017.06.2580650.332899
Handanovic3250PInterHandanovicNaN6443719840...20.426.5393.015.03.810.00.2711.26.1621620.533399
Berisha4316PTorinoBerishaNaN6373219890...87.258.6148.07.04.710.01.0014.66.1000000.700000
..................................................................
Kokorin5455391AFiorentinaKokorinNaN2833019916...0.00.00.00.00.00.00.000.05.9015180.269227
Munteanu5465458AFiorentinaMunteanuNaN-1000...0.00.00.00.00.00.00.000.06.2152330.275498
Buksa5475459AGenoaBuksaNaN831820034...0.00.00.00.00.00.00.000.06.0353190.591212
Kaio Jorge5485505AJuventusJorgeNaN2661920029...0.00.00.00.00.00.00.000.06.1377900.468234
Lazetic5495785AMilanLazeticNaN-1000...0.00.00.00.00.00.00.000.06.3253660.472207
\n", "

550 rows × 165 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age \\\n", "name \n", "Maignan 0 4312 P Milan Maignan NaN 647 26 \n", "Szczesny 1 453 P Juventus Szczesny NaN 675 31 \n", "Ospina 2 2468 P Napoli Ospina NaN 653 32 \n", "Handanovic 3 250 P Inter Handanovic NaN 644 37 \n", "Berisha 4 316 P Torino Berisha NaN 637 32 \n", "... ... ... .. ... ... ... ... ... \n", "Kokorin 545 5391 A Fiorentina Kokorin NaN 283 30 \n", "Munteanu 546 5458 A Fiorentina Munteanu NaN -1 0 \n", "Buksa 547 5459 A Genoa Buksa NaN 83 18 \n", "Kaio Jorge 548 5505 A Juventus Jorge NaN 266 19 \n", "Lazetic 549 5785 A Milan Lazetic NaN -1 0 \n", "\n", " birth_year games ... gk_pct_goal_kicks_launched \\\n", "name ... \n", "Maignan 1995 0 ... 38.9 \n", "Szczesny 1990 0 ... 29.7 \n", "Ospina 1988 0 ... 14.1 \n", "Handanovic 1984 0 ... 20.4 \n", "Berisha 1989 0 ... 87.2 \n", "... ... ... ... ... \n", "Kokorin 1991 6 ... 0.0 \n", "Munteanu 0 0 ... 0.0 \n", "Buksa 2003 4 ... 0.0 \n", "Kaio Jorge 2002 9 ... 0.0 \n", "Lazetic 0 0 ... 0.0 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "name \n", "Maignan 36.5 347.0 25.0 \n", "Szczesny 31.5 481.0 24.0 \n", "Ospina 22.5 353.0 18.0 \n", "Handanovic 26.5 393.0 15.0 \n", "Berisha 58.6 148.0 7.0 \n", "... ... ... ... \n", "Kokorin 0.0 0.0 0.0 \n", "Munteanu 0.0 0.0 0.0 \n", "Buksa 0.0 0.0 0.0 \n", "Kaio Jorge 0.0 0.0 0.0 \n", "Lazetic 0.0 0.0 0.0 \n", "\n", " gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n", "name \n", "Maignan 7.2 45.0 \n", "Szczesny 5.0 25.0 \n", "Ospina 5.1 31.0 \n", "Handanovic 3.8 10.0 \n", "Berisha 4.7 10.0 \n", "... ... ... \n", "Kokorin 0.0 0.0 \n", "Munteanu 0.0 0.0 \n", "Buksa 0.0 0.0 \n", "Kaio Jorge 0.0 0.0 \n", "Lazetic 0.0 0.0 \n", "\n", " gk_def_actions_outside_pen_area_per90 \\\n", "name \n", "Maignan 1.41 \n", "Szczesny 0.76 \n", "Ospina 1.00 \n", "Handanovic 0.27 \n", "Berisha 1.00 \n", "... ... \n", "Kokorin 0.00 \n", "Munteanu 0.00 \n", "Buksa 0.00 \n", "Kaio Jorge 0.00 \n", "Lazetic 0.00 \n", "\n", " gk_avg_distance_def_actions vote_avg vote_std \n", "name \n", "Maignan 16.8 6.265625 0.483871 \n", "Szczesny 13.5 6.121212 0.628012 \n", "Ospina 17.0 6.258065 0.332899 \n", "Handanovic 11.2 6.162162 0.533399 \n", "Berisha 14.6 6.100000 0.700000 \n", "... ... ... ... \n", "Kokorin 0.0 5.901518 0.269227 \n", "Munteanu 0.0 6.215233 0.275498 \n", "Buksa 0.0 6.035319 0.591212 \n", "Kaio Jorge 0.0 6.137790 0.468234 \n", "Lazetic 0.0 6.325366 0.472207 \n", "\n", "[550 rows x 165 columns]" ] }, "execution_count": 47, "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": 48, "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": 49, "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
Immobile438785ALazioImmobileNaN25831199031...491.0488.069.04.06.03.02240.0518.0685.043.1
\n", "

1 rows × 791 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 id r team surname initial fb_ID age birth_year \\\n", "Immobile 438 785 A Lazio Immobile NaN 258 31 1990 \n", "\n", " games ... opp_vs_team_fouls opp_vs_team_fouled \\\n", "Immobile 31 ... 491.0 488.0 \n", "\n", " opp_vs_team_offsides opp_vs_team_pens_won \\\n", "Immobile 69.0 4.0 \n", "\n", " opp_vs_team_pens_conceded opp_vs_team_own_goals \\\n", "Immobile 6.0 3.0 \n", "\n", " opp_vs_team_ball_recoveries opp_vs_team_aerials_won \\\n", "Immobile 2240.0 518.0 \n", "\n", " opp_vs_team_aerials_lost opp_vs_team_aerials_won_pct \n", "Immobile 685.0 43.1 \n", "\n", "[1 rows x 791 columns]" ] }, "execution_count": 49, "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": 50, "id": "6b4c1b00", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Lazio'" ] }, "execution_count": 50, "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": 51, "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", " '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": 51, "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": 52, "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", "\n", "features_rel_gamecorr = [\n", " 'goals',\n", " 'assists',\n", " 'xg',\n", " 'npxg',\n", " 'cards_yellow',\n", " 'cards_red'\n", "]" ] }, { "cell_type": "code", "execution_count": 53, "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": 54, "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_pctdribble_tackles_pctdribbles_completed_pct...touches_live_balldribbles_completeddribblespasses_receivedmiscontrolsdispossessedfoulsfouledaerials_wonaerials_lost
ImmobileA3131271145.90.180.477.06.747.5...0.4304680.0070080.0147550.3629660.0284030.016230.0132790.0143860.0081150.016968
\n", "

1 rows × 121 columns

\n", "
" ], "text/plain": [ " r games games_starts minutes shots_on_target_pct \\\n", "Immobile A 31 31 2711 45.9 \n", "\n", " goals_per_shot goals_per_shot_on_target passes_pct \\\n", "Immobile 0.18 0.4 77.0 \n", "\n", " dribble_tackles_pct dribbles_completed_pct ... touches_live_ball \\\n", "Immobile 6.7 47.5 ... 0.430468 \n", "\n", " dribbles_completed dribbles passes_received miscontrols \\\n", "Immobile 0.007008 0.014755 0.362966 0.028403 \n", "\n", " dispossessed fouls fouled aerials_won aerials_lost \n", "Immobile 0.01623 0.013279 0.014386 0.008115 0.016968 \n", "\n", "[1 rows x 121 columns]" ] }, "execution_count": 54, "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": 55, "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
01MussoAtalantaTorino06.0-100.54.5
11Pezzella Giu.AtalantaTorino06.0000.06.0
21DjimsitiAtalantaTorino06.0000.06.0
31GosensAtalantaTorino05.5000.05.5
41PalominoAtalantaTorino06.5000.06.5
.................................
1064938TamezeVeronaLazio05.5000.05.5
1065038HonglaVeronaLazio07.0100.59.5
1065138LasagnaVeronaLazio07.0100.59.5
1065238CaprariVeronaLazio06.0000.06.0
1065338SimeoneVeronaLazio07.0100.010.0
\n", "

10654 rows × 10 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Torino 0 6.0 -1 0 \n", "1 1 Pezzella Giu. Atalanta Torino 0 6.0 0 0 \n", "2 1 Djimsiti Atalanta Torino 0 6.0 0 0 \n", "3 1 Gosens Atalanta Torino 0 5.5 0 0 \n", "4 1 Palomino Atalanta Torino 0 6.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "10649 38 Tameze Verona Lazio 0 5.5 0 0 \n", "10650 38 Hongla Verona Lazio 0 7.0 1 0 \n", "10651 38 Lasagna Verona Lazio 0 7.0 1 0 \n", "10652 38 Caprari Verona Lazio 0 6.0 0 0 \n", "10653 38 Simeone Verona Lazio 0 7.0 1 0 \n", "\n", " cards_malus fantavote \n", "0 0.5 4.5 \n", "1 0.0 6.0 \n", "2 0.0 6.0 \n", "3 0.0 5.5 \n", "4 0.0 6.5 \n", "... ... ... \n", "10649 0.0 5.5 \n", "10650 0.5 9.5 \n", "10651 0.5 9.5 \n", "10652 0.0 6.0 \n", "10653 0.0 10.0 \n", "\n", "[10654 rows x 10 columns]" ] }, "execution_count": 55, "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": 69, "id": "ec0bc56b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\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", "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", "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", "10600\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": 70, "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...touches_live_balldribbles_completeddribblespasses_receivedmiscontrolsdispossessedfoulsfouledaerials_wonaerials_lost
01MussoAtalantaTorino06.0-100.56.5...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
11Pezzella Giu.AtalantaTorino06.0000.06.0...0.7285450.0074630.0177240.4580220.0167910.0111940.0177240.0279850.0130600.013060
21DjimsitiAtalantaTorino06.0000.06.0...0.7318260.0017730.0026600.4605500.0079790.0013300.0093090.0062060.0252660.011968
31GosensAtalantaTorino05.5000.05.5...0.7455620.0000000.0059170.4733730.0177510.0000000.0059170.0118340.0236690.005917
41PalominoAtalantaTorino06.5000.06.5...0.7526200.0022460.0029940.3993260.0056140.0026200.0145960.0063620.0392960.017964
..................................................................
1064938TamezeVeronaLazio05.5000.05.5...0.6293710.0132090.0233100.3581970.0198140.0101010.0128210.0132090.0236990.021368
1065038HonglaVeronaLazio07.0100.59.5...0.5821810.0015360.0076800.3410140.0184330.0122890.0230410.0076800.0230410.026114
1065138LasagnaVeronaLazio07.0100.59.5...0.3699320.0084460.0160470.2626690.0464530.0228040.0160470.0084460.0261820.041385
1065238CaprariVeronaLazio06.0000.06.0...0.6024100.0237310.0434470.4538150.0339540.0197150.0153340.0270170.0029210.009858
1065338SimeoneVeronaLazio07.0100.010.0...0.4070860.0086690.0229930.3203920.0512630.0301550.0211080.0218620.0226160.040709
\n", "

10654 rows × 131 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "0 1 Musso Atalanta Torino 0 6.0 -1 0 \n", "1 1 Pezzella Giu. Atalanta Torino 0 6.0 0 0 \n", "2 1 Djimsiti Atalanta Torino 0 6.0 0 0 \n", "3 1 Gosens Atalanta Torino 0 5.5 0 0 \n", "4 1 Palomino Atalanta Torino 0 6.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "10649 38 Tameze Verona Lazio 0 5.5 0 0 \n", "10650 38 Hongla Verona Lazio 0 7.0 1 0 \n", "10651 38 Lasagna Verona Lazio 0 7.0 1 0 \n", "10652 38 Caprari Verona Lazio 0 6.0 0 0 \n", "10653 38 Simeone Verona Lazio 0 7.0 1 0 \n", "\n", " cards_malus fantavote ... touches_live_ball dribbles_completed \\\n", "0 0.5 6.5 ... 0.000000 0.000000 \n", "1 0.0 6.0 ... 0.728545 0.007463 \n", "2 0.0 6.0 ... 0.731826 0.001773 \n", "3 0.0 5.5 ... 0.745562 0.000000 \n", "4 0.0 6.5 ... 0.752620 0.002246 \n", "... ... ... ... ... ... \n", "10649 0.0 5.5 ... 0.629371 0.013209 \n", "10650 0.5 9.5 ... 0.582181 0.001536 \n", "10651 0.5 9.5 ... 0.369932 0.008446 \n", "10652 0.0 6.0 ... 0.602410 0.023731 \n", "10653 0.0 10.0 ... 0.407086 0.008669 \n", "\n", " dribbles passes_received miscontrols dispossessed fouls \\\n", "0 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "1 0.017724 0.458022 0.016791 0.011194 0.017724 \n", "2 0.002660 0.460550 0.007979 0.001330 0.009309 \n", "3 0.005917 0.473373 0.017751 0.000000 0.005917 \n", "4 0.002994 0.399326 0.005614 0.002620 0.014596 \n", "... ... ... ... ... ... \n", "10649 0.023310 0.358197 0.019814 0.010101 0.012821 \n", "10650 0.007680 0.341014 0.018433 0.012289 0.023041 \n", "10651 0.016047 0.262669 0.046453 0.022804 0.016047 \n", "10652 0.043447 0.453815 0.033954 0.019715 0.015334 \n", "10653 0.022993 0.320392 0.051263 0.030155 0.021108 \n", "\n", " fouled aerials_won aerials_lost \n", "0 0.000000 0.000000 0.000000 \n", "1 0.027985 0.013060 0.013060 \n", "2 0.006206 0.025266 0.011968 \n", "3 0.011834 0.023669 0.005917 \n", "4 0.006362 0.039296 0.017964 \n", "... ... ... ... \n", "10649 0.013209 0.023699 0.021368 \n", "10650 0.007680 0.023041 0.026114 \n", "10651 0.008446 0.026182 0.041385 \n", "10652 0.027017 0.002921 0.009858 \n", "10653 0.021862 0.022616 0.040709 \n", "\n", "[10654 rows x 131 columns]" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "code", "execution_count": 71, "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": 72, "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...touches_live_balldribbles_completeddribblespasses_receivedmiscontrolsdispossessedfoulsfouledaerials_wonaerials_lost
11Pezzella Giu.AtalantaTorino06.0000.06.0...0.7285450.0074630.0177240.4580220.0167910.0111940.0177240.0279850.0130600.013060
21DjimsitiAtalantaTorino06.0000.06.0...0.7318260.0017730.0026600.4605500.0079790.0013300.0093090.0062060.0252660.011968
31GosensAtalantaTorino05.5000.05.5...0.7455620.0000000.0059170.4733730.0177510.0000000.0059170.0118340.0236690.005917
41PalominoAtalantaTorino06.5000.06.5...0.7526200.0022460.0029940.3993260.0056140.0026200.0145960.0063620.0392960.017964
51DemiralAtalantaTorino05.5000.55.0...0.5534690.0010430.0020870.2832550.0078250.0026080.0151280.0083460.0443400.019301
..................................................................
1064938TamezeVeronaLazio05.5000.05.5...0.6293710.0132090.0233100.3581970.0198140.0101010.0128210.0132090.0236990.021368
1065038HonglaVeronaLazio07.0100.59.5...0.5821810.0015360.0076800.3410140.0184330.0122890.0230410.0076800.0230410.026114
1065138LasagnaVeronaLazio07.0100.59.5...0.3699320.0084460.0160470.2626690.0464530.0228040.0160470.0084460.0261820.041385
1065238CaprariVeronaLazio06.0000.06.0...0.6024100.0237310.0434470.4538150.0339540.0197150.0153340.0270170.0029210.009858
1065338SimeoneVeronaLazio07.0100.010.0...0.4070860.0086690.0229930.3203920.0512630.0301550.0211080.0218620.0226160.040709
\n", "

9567 rows × 131 columns

\n", "
" ], "text/plain": [ " matchday player team oppteam home vote goals assists \\\n", "1 1 Pezzella Giu. Atalanta Torino 0 6.0 0 0 \n", "2 1 Djimsiti Atalanta Torino 0 6.0 0 0 \n", "3 1 Gosens Atalanta Torino 0 5.5 0 0 \n", "4 1 Palomino Atalanta Torino 0 6.5 0 0 \n", "5 1 Demiral Atalanta Torino 0 5.5 0 0 \n", "... ... ... ... ... ... ... ... ... \n", "10649 38 Tameze Verona Lazio 0 5.5 0 0 \n", "10650 38 Hongla Verona Lazio 0 7.0 1 0 \n", "10651 38 Lasagna Verona Lazio 0 7.0 1 0 \n", "10652 38 Caprari Verona Lazio 0 6.0 0 0 \n", "10653 38 Simeone Verona Lazio 0 7.0 1 0 \n", "\n", " cards_malus fantavote ... touches_live_ball dribbles_completed \\\n", "1 0.0 6.0 ... 0.728545 0.007463 \n", "2 0.0 6.0 ... 0.731826 0.001773 \n", "3 0.0 5.5 ... 0.745562 0.000000 \n", "4 0.0 6.5 ... 0.752620 0.002246 \n", "5 0.5 5.0 ... 0.553469 0.001043 \n", "... ... ... ... ... ... \n", "10649 0.0 5.5 ... 0.629371 0.013209 \n", "10650 0.5 9.5 ... 0.582181 0.001536 \n", "10651 0.5 9.5 ... 0.369932 0.008446 \n", "10652 0.0 6.0 ... 0.602410 0.023731 \n", "10653 0.0 10.0 ... 0.407086 0.008669 \n", "\n", " dribbles passes_received miscontrols dispossessed fouls \\\n", "1 0.017724 0.458022 0.016791 0.011194 0.017724 \n", "2 0.002660 0.460550 0.007979 0.001330 0.009309 \n", "3 0.005917 0.473373 0.017751 0.000000 0.005917 \n", "4 0.002994 0.399326 0.005614 0.002620 0.014596 \n", "5 0.002087 0.283255 0.007825 0.002608 0.015128 \n", "... ... ... ... ... ... \n", "10649 0.023310 0.358197 0.019814 0.010101 0.012821 \n", "10650 0.007680 0.341014 0.018433 0.012289 0.023041 \n", "10651 0.016047 0.262669 0.046453 0.022804 0.016047 \n", "10652 0.043447 0.453815 0.033954 0.019715 0.015334 \n", "10653 0.022993 0.320392 0.051263 0.030155 0.021108 \n", "\n", " fouled aerials_won aerials_lost \n", "1 0.027985 0.013060 0.013060 \n", "2 0.006206 0.025266 0.011968 \n", "3 0.011834 0.023669 0.005917 \n", "4 0.006362 0.039296 0.017964 \n", "5 0.008346 0.044340 0.019301 \n", "... ... ... ... \n", "10649 0.013209 0.023699 0.021368 \n", "10650 0.007680 0.023041 0.026114 \n", "10651 0.008446 0.026182 0.041385 \n", "10652 0.027017 0.002921 0.009858 \n", "10653 0.021862 0.022616 0.040709 \n", "\n", "[9567 rows x 131 columns]" ] }, "execution_count": 72, "metadata": {}, "output_type": "execute_result" } ], "source": [ "db" ] }, { "cell_type": "code", "execution_count": 73, "id": "df26c8e0", "metadata": {}, "outputs": [], "source": [ "db.to_excel('mid_outputs/season' + season + '/database_entries.xlsx')" ] }, { "cell_type": "code", "execution_count": 56, "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": 57, "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": 58, "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
Consigli37.037.03322.01.7167.88.1-0.1643.229.030.9...56.00.28-6.0186.0431.01219.0174.0246.0491.021.0
\n", "

1 rows × 98 columns

\n", "
" ], "text/plain": [ " gk_games gk_games_starts gk_minutes gk_goals_against_per90 \\\n", "Consigli 37.0 37.0 3322.0 1.71 \n", "\n", " gk_save_pct gk_clean_sheets_pct gk_psxg_net_per90 \\\n", "Consigli 67.8 8.1 -0.16 \n", "\n", " gk_passes_pct_launched gk_pct_passes_launched \\\n", "Consigli 43.2 29.0 \n", "\n", " gk_passes_length_avg ... gk_psxg \\\n", "Consigli 30.9 ... 56.0 \n", "\n", " gk_psnpxg_per_shot_on_target_against gk_psxg_net \\\n", "Consigli 0.28 -6.0 \n", "\n", " gk_passes_completed_launched gk_passes_launched gk_passes \\\n", "Consigli 186.0 431.0 1219.0 \n", "\n", " gk_passes_throws gk_goal_kicks gk_crosses gk_crosses_stopped \n", "Consigli 174.0 246.0 491.0 21.0 \n", "\n", "[1 rows x 98 columns]" ] }, "execution_count": 58, "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": null, "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" ] } ], "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": null, "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": null, "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 }