3428 lines
144 KiB
Plaintext
3428 lines
144 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "b2cd2177",
|
||
"metadata": {},
|
||
"source": [
|
||
"Players dataset creation\n",
|
||
"\n",
|
||
"The Fantacalcio players list is manually downloaded from https://www.fantacalcio.it/quotazioni-fantacalcio\n",
|
||
"\n",
|
||
"Here, the players database is generated, by merging the Fantacalcio list to stats downloaded from http://fbref.com"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 1,
|
||
"id": "7c65df92",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import pandas as pd"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "5ab35d0c",
|
||
"metadata": {},
|
||
"source": [
|
||
"Load fbref data for outfield players and goalkeepers.\n",
|
||
"\n",
|
||
"Generate fbref player list, adding player surname (with special characters replaced to normal ones)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 2,
|
||
"id": "b2d7073e",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"rcsv = pd.read_csv('fbref_data/outfield_players.csv') \n",
|
||
"outfield_players = pd.DataFrame(rcsv)\n",
|
||
"\n",
|
||
"rcsv = pd.read_csv('fbref_data/keepers_players.csv') \n",
|
||
"keeper_players = pd.DataFrame(rcsv)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"id": "667970f6",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>player</th>\n",
|
||
" <th>team</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Francesco Acerbi</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Michel Aebischer</td>\n",
|
||
" <td>Bologna</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Luis Alberto</td>\n",
|
||
" <td>Lazio</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Pontus Almqvist</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>Lorenzo Amatucci</td>\n",
|
||
" <td>Fiorentina</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>452</th>\n",
|
||
" <td>Yann Sommer</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>453</th>\n",
|
||
" <td>Alessandro Sorrentino</td>\n",
|
||
" <td>Monza</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>454</th>\n",
|
||
" <td>Wojciech Szczęsny</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>455</th>\n",
|
||
" <td>Pietro Terracciano</td>\n",
|
||
" <td>Fiorentina</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>456</th>\n",
|
||
" <td>Stefano Turati</td>\n",
|
||
" <td>Frosinone</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>457 rows × 2 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" player team\n",
|
||
"0 Francesco Acerbi Inter\n",
|
||
"1 Michel Aebischer Bologna\n",
|
||
"2 Luis Alberto Lazio\n",
|
||
"3 Pontus Almqvist Lecce\n",
|
||
"4 Lorenzo Amatucci Fiorentina\n",
|
||
".. ... ...\n",
|
||
"452 Yann Sommer Inter\n",
|
||
"453 Alessandro Sorrentino Monza\n",
|
||
"454 Wojciech Szczęsny Juventus\n",
|
||
"455 Pietro Terracciano Fiorentina\n",
|
||
"456 Stefano Turati Frosinone\n",
|
||
"\n",
|
||
"[457 rows x 2 columns]"
|
||
]
|
||
},
|
||
"execution_count": 3,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"players = pd.concat( [ outfield_players[['player', 'team']], keeper_players[['player', 'team']] ], axis = 0, ignore_index = True)\n",
|
||
"\n",
|
||
"keepers_ID = len(outfield_players)\n",
|
||
"\n",
|
||
"players"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"id": "e1e64596",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import unicodedata\n",
|
||
"\n",
|
||
"def normalize_name(input_str):\n",
|
||
" nfkd_form = unicodedata.normalize('NFKD', input_str)\n",
|
||
" only_ascii = nfkd_form.encode('ASCII', 'ignore')\n",
|
||
" return only_ascii.decode('utf-8')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"id": "3078d6f3",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"players['surname'] = players['player']\n",
|
||
"players['initial'] = players['player']\n",
|
||
"\n",
|
||
"for i in range(players.shape[0]):\n",
|
||
" players['surname'][i] = players['surname'][i].split(' ')[-1]\n",
|
||
" players['surname'][i] = normalize_name(players['surname'][i]).replace('\\'', '')\n",
|
||
" \n",
|
||
" \n",
|
||
" players['initial'][i] = players['player'][i][0]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"id": "ffd6091c",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
" player surname\n",
|
||
"0 Francesco Acerbi Acerbi\n",
|
||
"1 Michel Aebischer Aebischer\n",
|
||
"2 Luis Alberto Alberto\n",
|
||
"3 Pontus Almqvist Almqvist\n",
|
||
"4 Lorenzo Amatucci Amatucci\n",
|
||
"5 Bruno Amione Amione\n",
|
||
"6 Felipe Anderson Anderson\n",
|
||
"7 Houssem Aouar Aouar\n",
|
||
"8 Marko Arnautović Arnautovic\n",
|
||
"9 Kristjan Asllani Asllani\n",
|
||
"10 Tommaso Augello Augello\n",
|
||
"11 Yann Aurel Bisseck Bisseck\n",
|
||
"12 Sardar Azmoun Azmoun\n",
|
||
"13 Paulo Azzi Azzi\n",
|
||
"14 Oussama El Azzouzi Azzouzi\n",
|
||
"15 Milan Badelj Badelj\n",
|
||
"16 Jaime Báez Baez\n",
|
||
"17 Nedim Bajrami Bajrami\n",
|
||
"18 Mitchel Bakker Bakker\n",
|
||
"19 Tommaso Baldanzi Baldanzi\n",
|
||
"20 Lameck Banda Banda\n",
|
||
"21 Mattia Bani Bani\n",
|
||
"22 Antonín Barák Barak\n",
|
||
"23 Nicolò Barella Barella\n",
|
||
"24 Enzo Barrenechea Barrenechea\n",
|
||
"25 Federico Baschirotto Baschirotto\n",
|
||
"26 Alessandro Bastoni Bastoni\n",
|
||
"27 Simone Bastoni Bastoni\n",
|
||
"28 Raoul Bellanova Bellanova\n",
|
||
"29 Andrea Belotti Belotti\n",
|
||
"30 Lucas Beltrán Beltran\n",
|
||
"31 Domenico Berardi Berardi\n",
|
||
"32 Bartosz Bereszyński Bereszynski\n",
|
||
"33 Etrit Berisha Berisha\n",
|
||
"34 Victor Bernth Kristiansen Kristiansen\n",
|
||
"35 Beto Beto\n",
|
||
"36 Sam Beukema Beukema\n",
|
||
"37 Jaka Bijol Bijol\n",
|
||
"38 Cristiano Biraghi Biraghi\n",
|
||
"39 Davide Biraschi Biraschi\n",
|
||
"40 Samuele Birindelli Birindelli\n",
|
||
"41 Alexis Blin Blin\n",
|
||
"42 Emil Bohinen Bohinen\n",
|
||
"43 Daniel Boloca Boloca\n",
|
||
"44 Giacomo Bonaventura Bonaventura\n",
|
||
"45 Federico Bonazzoli Bonazzoli\n",
|
||
"46 Warren Bondo Bondo\n",
|
||
"47 Gennaro Borrelli Borrelli\n",
|
||
"48 Erik Botheim Botheim\n",
|
||
"49 Edoardo Bove Bove\n",
|
||
"50 Domagoj Bradarić Bradaric\n",
|
||
"51 Josip Brekalo Brekalo\n",
|
||
"52 Gleison Bremer Bremer\n",
|
||
"53 Marco Brescianini Brescianini\n",
|
||
"54 Alessandro Buongiorno Buongiorno\n",
|
||
"55 Rareș-Cătălin Burnete Burnete\n",
|
||
"56 Juan Cabal Cabal\n",
|
||
"57 Jovane Cabral Cabral\n",
|
||
"58 Liberato Cacace Cacace\n",
|
||
"59 Jens Cajuste Cajuste\n",
|
||
"60 Davide Calabria Calabria\n",
|
||
"61 Riccardo Calafiori Calafiori\n",
|
||
"62 Luca Caldirola Caldirola\n",
|
||
"63 Hakan Çalhanoğlu Calhanoglu\n",
|
||
"64 Nicolò Cambiaghi Cambiaghi\n",
|
||
"65 Andrea Cambiaso Cambiaso\n",
|
||
"66 Matteo Cancellieri Cancellieri\n",
|
||
"67 Antonio Candreva Candreva\n",
|
||
"68 Luigi Canotto Canotto\n",
|
||
"69 Gianluca Caprari Caprari\n",
|
||
"70 Elia Caprile Caprile\n",
|
||
"71 Francesco Caputo Caputo\n",
|
||
"72 Andrea Carboni Carboni\n",
|
||
"73 Valentin Carboni Carboni\n",
|
||
"74 Carlos Carlos\n",
|
||
"75 Marco Carnesecchi Carnesecchi\n",
|
||
"76 Nicolò Casale Casale\n",
|
||
"77 Giuseppe Caso Caso\n",
|
||
"78 Valentín Castellanos Castellanos\n",
|
||
"79 Samu Castillejo Castillejo\n",
|
||
"80 Danilo Cataldi Cataldi\n",
|
||
"81 Emil Ceide Ceide\n",
|
||
"82 Zeki Çelik Celik\n",
|
||
"83 Michele Cerofolini Cerofolini\n",
|
||
"84 Walid Cheddira Cheddira\n",
|
||
"85 Federico Chiesa Chiesa\n",
|
||
"86 Oliver Christensen Christensen\n",
|
||
"87 Samuel Chukwueze Chukwueze\n",
|
||
"88 Patrick Ciurria Ciurria\n",
|
||
"89 Lorenzo Colombo Colombo\n",
|
||
"90 Andrea Colpani Colpani\n",
|
||
"91 Andrea Consigli Consigli\n",
|
||
"92 Diego Coppola Coppola\n",
|
||
"93 Tommaso Corazza Corazza\n",
|
||
"94 Lassana Coulibaly Coulibaly\n",
|
||
"95 Mamadou Coulibaly Coulibaly\n",
|
||
"96 Alessio Cragno Cragno\n",
|
||
"97 Bryan Cristante Cristante\n",
|
||
"98 Juan Cuadrado Cuadrado\n",
|
||
"99 Marvin Cuni Cuni\n",
|
||
"100 Danilo D'Ambrosio DAmbrosio\n",
|
||
"101 Danilo Danilo\n",
|
||
"102 Matteo Darmian Darmian\n",
|
||
"103 Paweł Dawidowicz Dawidowicz\n",
|
||
"104 Charles De Ketelaere Ketelaere\n",
|
||
"105 Lorenzo De Silvestri Silvestri\n",
|
||
"106 Koni De Winter Winter\n",
|
||
"107 Grégoire Defrel Defrel\n",
|
||
"108 Alessandro Deiola Deiola\n",
|
||
"109 Mattia Destro Destro\n",
|
||
"110 Federico Di Francesco Francesco\n",
|
||
"111 Michele Di Gregorio Gregorio\n",
|
||
"112 Giovanni Di Lorenzo Lorenzo\n",
|
||
"113 Alessandro Di Pardo Pardo\n",
|
||
"114 Boulaye Dia Dia\n",
|
||
"115 Federico Dimarco Dimarco\n",
|
||
"116 Berat Djimsiti Djimsiti\n",
|
||
"117 Dodô Dodo\n",
|
||
"118 Josh Doig Doig\n",
|
||
"119 Nicolás Domínguez Dominguez\n",
|
||
"120 Patrick Dorgu Dorgu\n",
|
||
"121 Alberto Dossena Dossena\n",
|
||
"122 Radu Drăgușin Dragusin\n",
|
||
"123 Ondrej Duda Duda\n",
|
||
"124 Denzel Dumfries Dumfries\n",
|
||
"125 Alfred Duncan Duncan\n",
|
||
"126 Paulo Dybala Dybala\n",
|
||
"127 Festy Ebosele Ebosele\n",
|
||
"128 Enzo Ebosse Ebosse\n",
|
||
"129 Tyronne Ebuehi Ebuehi\n",
|
||
"130 Éderson Ederson\n",
|
||
"131 Emmanuel Ekong Ekong\n",
|
||
"132 Caleb Ekuban Ekuban\n",
|
||
"133 Elif Elmas Elmas\n",
|
||
"134 Martin Erlic Erlic\n",
|
||
"135 Giovanni Fabbian Fabbian\n",
|
||
"136 Nicolò Fagioli Fagioli\n",
|
||
"137 Wladimiro Falcone Falcone\n",
|
||
"138 Davide Faraoni Faraoni\n",
|
||
"139 Federico Fazio Fazio\n",
|
||
"140 Jacopo Fazzini Fazzini\n",
|
||
"141 Lewis Ferguson Ferguson\n",
|
||
"142 João Ferreira Ferreira\n",
|
||
"143 Alessandro Florenzi Florenzi\n",
|
||
"144 Michael Folorunsho Folorunsho\n",
|
||
"145 Davide Frattesi Frattesi\n",
|
||
"146 Morten Frendrup Frendrup\n",
|
||
"147 Remo Freuler Freuler\n",
|
||
"148 Roberto Gagliardini Gagliardini\n",
|
||
"149 Antonino Gallo Gallo\n",
|
||
"150 Luca Garritano Garritano\n",
|
||
"151 Federico Gatti Gatti\n",
|
||
"152 Francesco Gelli Gelli\n",
|
||
"153 Valentin Gendrey Gendrey\n",
|
||
"154 Gvidas Gineitis Gineitis\n",
|
||
"155 Olivier Giroud Giroud\n",
|
||
"156 Edoardo Goldaniga Goldaniga\n",
|
||
"157 Joan Gonzàlez Gonzalez\n",
|
||
"158 Nicolás González Gonzalez\n",
|
||
"159 Alberto Grassi Grassi\n",
|
||
"160 Mattéo Guendouzi Guendouzi\n",
|
||
"161 Axel Guessand Guessand\n",
|
||
"162 Albert Guðmundsson Gumundsson\n",
|
||
"163 Emmanuel Gyasi Gyasi\n",
|
||
"164 Norbert Gyömbér Gyomber\n",
|
||
"165 Nicolas Haas Haas\n",
|
||
"166 Abdou Harroui Harroui\n",
|
||
"167 Pantelis Hatzidiakos Hatzidiakos\n",
|
||
"168 Silvan Hefti Hefti\n",
|
||
"169 Liam Henderson Henderson\n",
|
||
"170 Matheus Henrique Henrique\n",
|
||
"171 Theo Hernández Hernandez\n",
|
||
"172 Isak Hien Hien\n",
|
||
"173 Emil Holm Holm\n",
|
||
"174 Martin Hongla Hongla\n",
|
||
"175 Sydney van Hooijdonk Hooijdonk\n",
|
||
"176 Elseid Hysaj Hysaj\n",
|
||
"177 Chukwubuikem Ikwuemesi Ikwuemesi\n",
|
||
"178 Ivan Ilić Ilic\n",
|
||
"179 Samuel Iling-Junior Iling-Junior\n",
|
||
"180 Ciro Immobile Immobile\n",
|
||
"181 Gino Infantino Infantino\n",
|
||
"182 Gustav Isaksen Isaksen\n",
|
||
"183 Ardian Ismajli Ismajli\n",
|
||
"184 Armando Izzo Izzo\n",
|
||
"185 Filip Jagiełło Jagieo\n",
|
||
"186 Jakub Jankto Jankto\n",
|
||
"187 Juan Jesus Jesus\n",
|
||
"188 Luka Jović Jovic\n",
|
||
"189 Mohamed Kaba Kaba\n",
|
||
"190 Christian Kabasele Kabasele\n",
|
||
"191 Pierre Kalulu Kalulu\n",
|
||
"192 Daichi Kamada Kamada\n",
|
||
"193 Hassane Kamara Kamara\n",
|
||
"194 Yann Karamoh Karamoh\n",
|
||
"195 Jesper Karlsson Karlsson\n",
|
||
"196 Rick Karsdorp Karsdorp\n",
|
||
"197 Grigoris Kastanos Kastanos\n",
|
||
"198 Michael Kayode Kayode\n",
|
||
"199 Moise Kean Kean\n",
|
||
"200 Simon Kjær Kjr\n",
|
||
"201 Sead Kolašinac Kolasinac\n",
|
||
"202 Teun Koopmeiners Koopmeiners\n",
|
||
"203 Filip Kostić Kostic\n",
|
||
"204 Christian Kouamé Kouame\n",
|
||
"205 Viktor Kovalenko Kovalenko\n",
|
||
"206 Nikola Krstović Krstovic\n",
|
||
"207 Rade Krunić Krunic\n",
|
||
"208 Berkan Kutlu Kutlu\n",
|
||
"209 Khvicha Kvaratskhelia Kvaratskhelia\n",
|
||
"210 Giorgi Kvernadze Kvernadze\n",
|
||
"211 Giorgos Kyriakopoulos Kyriakopoulos\n",
|
||
"212 Armand Lauriente Lauriente\n",
|
||
"213 Valentino Lazaro Lazaro\n",
|
||
"214 Darko Lazović Lazovic\n",
|
||
"215 Manuel Lazzari Lazzari\n",
|
||
"216 Rafael Leão Leao\n",
|
||
"217 Jesper Lindstrøm Lindstrm\n",
|
||
"218 Karol Linetty Linetty\n",
|
||
"219 Pol Lirola Lirola\n",
|
||
"220 Diego Llorente Llorente\n",
|
||
"221 Stanislav Lobotka Lobotka\n",
|
||
"222 Manuel Locatelli Locatelli\n",
|
||
"223 Ruben Loftus-Cheek Loftus-Cheek\n",
|
||
"224 Ademola Lookman Lookman\n",
|
||
"225 Maxime Lopez Lopez\n",
|
||
"226 Matteo Lovato Lovato\n",
|
||
"227 Sandi Lovrić Lovric\n",
|
||
"228 Lorenzo Lucca Lucca\n",
|
||
"229 Jhon Lucumí Lucumi\n",
|
||
"230 José Luis Palomino Palomino\n",
|
||
"231 Romelu Lukaku Lukaku\n",
|
||
"232 Sebastiano Luperto Luperto\n",
|
||
"233 Charalambos Lykogiannis Lykogiannis\n",
|
||
"234 Giulio Maggiore Maggiore\n",
|
||
"235 Giangiacomo Magnani Magnani\n",
|
||
"236 Mike Maignan Maignan\n",
|
||
"237 Antoine Makoumbou Makoumbou\n",
|
||
"238 Youssef Maleh Maleh\n",
|
||
"239 Ruslan Malinovskyi Malinovskyi\n",
|
||
"240 Gianluca Mancini Mancini\n",
|
||
"241 Rolando Mandragora Mandragora\n",
|
||
"242 Riccardo Marchizza Marchizza\n",
|
||
"243 Pablo Marí Mari\n",
|
||
"244 Mirko Marić Maric\n",
|
||
"245 Răzvan Marin Marin\n",
|
||
"246 Agustín Martegani Martegani\n",
|
||
"247 Aarón Martín Martin\n",
|
||
"248 Josep Martinez Martinez\n",
|
||
"249 Lautaro Martínez Martinez\n",
|
||
"250 Lucas Martínez Quarta Quarta\n",
|
||
"251 Adam Marušić Marusic\n",
|
||
"252 Luca Mazzitelli Mazzitelli\n",
|
||
"253 Pasquale Mazzocchi Mazzocchi\n",
|
||
"254 Jordi Mboula Mboula\n",
|
||
"255 Weston McKennie McKennie\n",
|
||
"256 Arthur Melo Melo\n",
|
||
"257 Alex Meret Meret\n",
|
||
"258 Nikola Milenković Milenkovic\n",
|
||
"259 Arkadiusz Milik Milik\n",
|
||
"260 Vanja Milinković-Savić Milinkovic-Savic\n",
|
||
"261 Aleksei Miranchuk Miranchuk\n",
|
||
"262 Kevin Miranda Miranda\n",
|
||
"263 Fabio Miretti Miretti\n",
|
||
"264 Filippo Missori Missori\n",
|
||
"265 Henrikh Mkhitaryan Mkhitaryan\n",
|
||
"266 Ilario Monterisi Monterisi\n",
|
||
"267 Lorenzo Montipò Montipo\n",
|
||
"268 Nikola Moro Moro\n",
|
||
"269 Dany Mota Mota\n",
|
||
"270 Samuele Mulattieri Mulattieri\n",
|
||
"271 Luis Muriel Muriel\n",
|
||
"272 Yunus Musah Musah\n",
|
||
"273 Juan Musso Musso\n",
|
||
"274 Obite N'Dicka NDicka\n",
|
||
"275 Nahitan Nández Nandez\n",
|
||
"276 Michel Ndary Adopo Adopo\n",
|
||
"277 Dan Ndoye Ndoye\n",
|
||
"278 Cyril Ngonge Ngonge\n",
|
||
"279 Rasmus Nissen Nissen\n",
|
||
"280 M'Bala Nzola Nzola\n",
|
||
"281 Adam Obert Obert\n",
|
||
"282 Guillermo Ochoa Ochoa\n",
|
||
"283 Noah Okafor Okafor\n",
|
||
"284 Caleb Okoli Okoli\n",
|
||
"285 Mathías Olivera Olivera\n",
|
||
"286 Gaetano Oristanio Oristanio\n",
|
||
"287 Riccardo Orsolini Orsolini\n",
|
||
"288 Victor Osimhen Osimhen\n",
|
||
"289 Anthony Oyono Oyono\n",
|
||
"290 Riccardo Pagano Pagano\n",
|
||
"291 Leandro Paredes Paredes\n",
|
||
"292 Fabiano Parisi Parisi\n",
|
||
"293 Mario Pašalić Pasalic\n",
|
||
"294 Patric Patric\n",
|
||
"295 Rui Patrício Patricio\n",
|
||
"296 Leonardo Pavoletti Pavoletti\n",
|
||
"297 Martín Payero Payero\n",
|
||
"298 Marcus Pedersen Pedersen\n",
|
||
"299 Pedro Pedro\n",
|
||
"300 Pietro Pellegri Pellegri\n",
|
||
"301 Lorenzo Pellegrini Pellegrini\n",
|
||
"302 Luca Pellegrini Pellegrini\n",
|
||
"303 Pepín Pepin\n",
|
||
"304 Pedro Pereira Pereira\n",
|
||
"305 Roberto Pereyra Pereyra\n",
|
||
"306 Nehuén Pérez Perez\n",
|
||
"307 Mattia Perin Perin\n",
|
||
"308 Samuele Perisan Perisan\n",
|
||
"309 Matteo Pessina Pessina\n",
|
||
"310 Andrea Petagna Petagna\n",
|
||
"311 Giuseppe Pezzella Pezzella\n",
|
||
"312 Roberto Piccoli Piccoli\n",
|
||
"313 Roberto Piccoli Piccoli\n",
|
||
"314 Andrea Pinamonti Pinamonti\n",
|
||
"315 Lorenzo Pirola Pirola\n",
|
||
"316 Tommaso Pobega Pobega\n",
|
||
"317 Paul Pogba Pogba\n",
|
||
"318 Matteo Politano Politano\n",
|
||
"319 Marin Pongračić Pongracic\n",
|
||
"320 Stefan Posch Posch\n",
|
||
"321 Matteo Prati Prati\n",
|
||
"322 Ivan Provedel Provedel\n",
|
||
"323 Christian Pulisic Pulisic\n",
|
||
"324 Domingos Quina Quina\n",
|
||
"325 Adrien Rabiot Rabiot\n",
|
||
"326 Uroš Račić Racic\n",
|
||
"327 Nemanja Radonjić Radonjic\n",
|
||
"328 Boris Radunović Radunovic\n",
|
||
"329 Hamza Rafia Rafia\n",
|
||
"330 Ylber Ramadani Ramadani\n",
|
||
"331 Luca Ranieri Ranieri\n",
|
||
"332 Giacomo Raspadori Raspadori\n",
|
||
"333 Tijjani Reijnders Reijnders\n",
|
||
"334 Mateo Retegui Retegui\n",
|
||
"335 Samuele Ricci Ricci\n",
|
||
"336 Ricardo Rodríguez Rodriguez\n",
|
||
"337 Alessio Romagnoli Romagnoli\n",
|
||
"338 Simone Romagnoli Romagnoli\n",
|
||
"339 Marten de Roon Roon\n",
|
||
"340 Nicolò Rovella Rovella\n",
|
||
"341 Amir Rrahmani Rrahmani\n",
|
||
"342 Ruan Ruan\n",
|
||
"343 Matteo Ruggeri Ruggeri\n",
|
||
"344 Mário Rui Rui\n",
|
||
"345 Stefano Sabelli Sabelli\n",
|
||
"346 Lazar Samardzic Samardzic\n",
|
||
"347 Junior Sambia Sambia\n",
|
||
"348 Antonio Sanabria Sanabria\n",
|
||
"349 Renato Sanches Sanches\n",
|
||
"350 Alex Sandro Sandro\n",
|
||
"351 Riccardo Saponara Saponara\n",
|
||
"352 Giorgio Scalvini Scalvini\n",
|
||
"353 Gianluca Scamacca Scamacca\n",
|
||
"354 Perr Schuurs Schuurs\n",
|
||
"355 Demba Seck Seck\n",
|
||
"356 Vivaldo Semedo Semedo\n",
|
||
"357 Stefano Sensi Sensi\n",
|
||
"358 Suat Serdar Serdar\n",
|
||
"359 Stephan El Shaarawy Shaarawy\n",
|
||
"360 Eldor Shomurodov Shomurodov\n",
|
||
"361 Steven Shpendi Shpendi\n",
|
||
"362 Marco Silvestri Silvestri\n",
|
||
"363 Giovanni Simeone Simeone\n",
|
||
"364 Leo Skiri Østigård stigard\n",
|
||
"365 Łukasz Skorupski Skorupski\n",
|
||
"366 Chris Smalling Smalling\n",
|
||
"367 Ola Solbakken Solbakken\n",
|
||
"368 Yann Sommer Sommer\n",
|
||
"369 Brandon Soppy Soppy\n",
|
||
"370 Alessandro Sorrentino Sorrentino\n",
|
||
"371 Riccardo Sottil Sottil\n",
|
||
"372 Matìas Soulé Soule\n",
|
||
"373 Leonardo Spinazzola Spinazzola\n",
|
||
"374 Gabriel Strefezza Strefezza\n",
|
||
"375 Kevin Strootman Strootman\n",
|
||
"376 Isaac Success Success\n",
|
||
"377 Ibrahim Sulemana Sulemana\n",
|
||
"378 Tomáš Suslov Suslov\n",
|
||
"379 Wojciech Szczęsny Szczesny\n",
|
||
"380 Przemysław Szymiński Szyminski\n",
|
||
"381 Adrien Tameze Tameze\n",
|
||
"382 Loum Tchaouna Tchaouna\n",
|
||
"383 Filippo Terracciano Terracciano\n",
|
||
"384 Pietro Terracciano Terracciano\n",
|
||
"385 Florian Thauvin Thauvin\n",
|
||
"386 Malick Thiaw Thiaw\n",
|
||
"387 Morten Thorsby Thorsby\n",
|
||
"388 Kristian Thorstvedt Thorstvedt\n",
|
||
"389 Marcus Thuram Thuram\n",
|
||
"390 Jeremy Toljan Toljan\n",
|
||
"391 Rafael Tolói Toloi\n",
|
||
"392 Fikayo Tomori Tomori\n",
|
||
"393 Ahmed Touba Touba\n",
|
||
"394 Stefano Turati Turati\n",
|
||
"395 Kacper Urbanski Urbanski\n",
|
||
"396 Johan Vásquez Vasquez\n",
|
||
"397 Matías Vecino Vecino\n",
|
||
"398 Simone Verdi Verdi\n",
|
||
"399 Samuele Vignato Vignato\n",
|
||
"400 Matías Viña Vina\n",
|
||
"401 Mattia Viti Viti\n",
|
||
"402 Dušan Vlahović Vlahovic\n",
|
||
"403 Nikola Vlašić Vlasic\n",
|
||
"404 Mërgim Vojvoda Vojvoda\n",
|
||
"405 Cristian Volpato Volpato\n",
|
||
"406 Stefan de Vrij Vrij\n",
|
||
"407 Walace Walace\n",
|
||
"408 Sebastian Walukiewicz Walukiewicz\n",
|
||
"409 Timothy Weah Weah\n",
|
||
"410 Mateusz Wieteska Wieteska\n",
|
||
"411 Kenan Yıldız Yldz\n",
|
||
"412 Mattia Zaccagni Zaccagni\n",
|
||
"413 Nicola Zalewski Zalewski\n",
|
||
"414 Andre-Frank Zambo Anguissa Anguissa\n",
|
||
"415 Duván Zapata Zapata\n",
|
||
"416 Duván Zapata Zapata\n",
|
||
"417 Gabriele Zappa Zappa\n",
|
||
"418 Davide Zappacosta Zappacosta\n",
|
||
"419 Oier Zarraga Zarraga\n",
|
||
"420 Jordan Zemura Zemura\n",
|
||
"421 Alessio Zerbin Zerbin\n",
|
||
"422 Piotr Zieliński Zielinski\n",
|
||
"423 David Zima Zima\n",
|
||
"424 Joshua Zirkzee Zirkzee\n",
|
||
"425 Zito Zito\n",
|
||
"426 Nadir Zortea Zortea\n",
|
||
"427 Milan Đurić uric\n",
|
||
"428 Mateusz Łęgowski egowski\n",
|
||
"429 Etrit Berisha Berisha\n",
|
||
"430 Elia Caprile Caprile\n",
|
||
"431 Marco Carnesecchi Carnesecchi\n",
|
||
"432 Michele Cerofolini Cerofolini\n",
|
||
"433 Oliver Christensen Christensen\n",
|
||
"434 Andrea Consigli Consigli\n",
|
||
"435 Alessio Cragno Cragno\n",
|
||
"436 Michele Di Gregorio Gregorio\n",
|
||
"437 Wladimiro Falcone Falcone\n",
|
||
"438 Mike Maignan Maignan\n",
|
||
"439 Josep Martinez Martinez\n",
|
||
"440 Alex Meret Meret\n",
|
||
"441 Vanja Milinković-Savić Milinkovic-Savic\n",
|
||
"442 Lorenzo Montipò Montipo\n",
|
||
"443 Juan Musso Musso\n",
|
||
"444 Guillermo Ochoa Ochoa\n",
|
||
"445 Rui Patrício Patricio\n",
|
||
"446 Mattia Perin Perin\n",
|
||
"447 Samuele Perisan Perisan\n",
|
||
"448 Ivan Provedel Provedel\n",
|
||
"449 Boris Radunović Radunovic\n",
|
||
"450 Marco Silvestri Silvestri\n",
|
||
"451 Łukasz Skorupski Skorupski\n",
|
||
"452 Yann Sommer Sommer\n",
|
||
"453 Alessandro Sorrentino Sorrentino\n",
|
||
"454 Wojciech Szczęsny Szczesny\n",
|
||
"455 Pietro Terracciano Terracciano\n",
|
||
"456 Stefano Turati Turati\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"print(players[['player', 'surname']].to_string())"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "9ab06a5c",
|
||
"metadata": {},
|
||
"source": [
|
||
"Replace the surname for some specific players, according to config/name_fix.txt file.\n",
|
||
"\n",
|
||
"This is done for players for which the decoded fbref surname doesn't correspond to Fantacalcio list."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 7,
|
||
"id": "3e759b1b",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Ostigard\n",
|
||
"Augusto\n",
|
||
"Kjaer\n",
|
||
"Djuric\n",
|
||
"Gudmundsson\n"
|
||
]
|
||
},
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>FROM</th>\n",
|
||
" <th>TO</th>\n",
|
||
" <th>TEAM</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>stigard</td>\n",
|
||
" <td>Ostigard</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Min-jae</td>\n",
|
||
" <td>Kim</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Hjlund</td>\n",
|
||
" <td>Hojlund</td>\n",
|
||
" <td>Atalanta</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Gytkjr</td>\n",
|
||
" <td>Gytkjaer</td>\n",
|
||
" <td>Monza</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>Carlos</td>\n",
|
||
" <td>Augusto</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>Mhle</td>\n",
|
||
" <td>Maehle</td>\n",
|
||
" <td>Atalanta</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>Kjr</td>\n",
|
||
" <td>Kjaer</td>\n",
|
||
" <td>Milan</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>uricic</td>\n",
|
||
" <td>Djuricic</td>\n",
|
||
" <td>Sampdoria</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>uric</td>\n",
|
||
" <td>Djuric</td>\n",
|
||
" <td>Hellas Verona</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>Arthur</td>\n",
|
||
" <td>Cabral</td>\n",
|
||
" <td>Fiorentina</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>Martinez</td>\n",
|
||
" <td>Alvarez</td>\n",
|
||
" <td>Sassuolo</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>Gumundsson</td>\n",
|
||
" <td>Gudmundsson</td>\n",
|
||
" <td>Genoa</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>Kristensen</td>\n",
|
||
" <td>Nissen</td>\n",
|
||
" <td>Roma</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" FROM TO TEAM\n",
|
||
"0 stigard Ostigard Napoli\n",
|
||
"1 Min-jae Kim Napoli\n",
|
||
"2 Hjlund Hojlund Atalanta\n",
|
||
"3 Gytkjr Gytkjaer Monza\n",
|
||
"4 Carlos Augusto Inter\n",
|
||
"5 Mhle Maehle Atalanta\n",
|
||
"6 Kjr Kjaer Milan\n",
|
||
"7 uricic Djuricic Sampdoria\n",
|
||
"8 uric Djuric Hellas Verona\n",
|
||
"9 Arthur Cabral Fiorentina\n",
|
||
"10 Martinez Alvarez Sassuolo\n",
|
||
"11 Gumundsson Gudmundsson Genoa\n",
|
||
"12 Kristensen Nissen Roma"
|
||
]
|
||
},
|
||
"execution_count": 7,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"rcsv = pd.read_csv('config/name_fix.txt') \n",
|
||
"name_fix = pd.DataFrame(rcsv)\n",
|
||
"\n",
|
||
"for i in range(name_fix.shape[0]):\n",
|
||
" for j in range(players.shape[0]):\n",
|
||
" if(players['surname'][j].lower() == name_fix['FROM'][i].lower() and players['team'][j].lower() == name_fix['TEAM'][i].lower()):\n",
|
||
" players['surname'][j] = name_fix['TO'][i]\n",
|
||
" print(name_fix['TO'][i])\n",
|
||
"\n",
|
||
"name_fix\n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "3c686d9f",
|
||
"metadata": {},
|
||
"source": [
|
||
"Load players from Fantacalcio list."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 8,
|
||
"id": "f96eaaa1",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>id</th>\n",
|
||
" <th>r</th>\n",
|
||
" <th>name</th>\n",
|
||
" <th>team</th>\n",
|
||
" <th>surname</th>\n",
|
||
" <th>initial</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>2428</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>453</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>572</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>2814</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td>Lazio</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>4312</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td>Milan</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>534</th>\n",
|
||
" <td>6395</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Shpendi S.</td>\n",
|
||
" <td>Empoli</td>\n",
|
||
" <td>Shpendi</td>\n",
|
||
" <td>S</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>535</th>\n",
|
||
" <td>6418</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>536</th>\n",
|
||
" <td>6419</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>537</th>\n",
|
||
" <td>6427</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td>Salernitana</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>538</th>\n",
|
||
" <td>6434</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td></td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>539 rows × 6 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" id r name team surname initial\n",
|
||
"0 2428 P Sommer Inter Sommer \n",
|
||
"1 453 P Szczesny Juventus Szczesny \n",
|
||
"2 572 P Meret Napoli Meret \n",
|
||
"3 2814 P Provedel Lazio Provedel \n",
|
||
"4 4312 P Maignan Milan Maignan \n",
|
||
".. ... .. ... ... ... ...\n",
|
||
"534 6395 A Shpendi S. Empoli Shpendi S\n",
|
||
"535 6418 A Burnete Lecce Burnete \n",
|
||
"536 6419 A Corfitzen Lecce Corfitzen \n",
|
||
"537 6427 A Stewart Salernitana Stewart \n",
|
||
"538 6434 A Yildiz Juventus Yildiz \n",
|
||
"\n",
|
||
"[539 rows x 6 columns]"
|
||
]
|
||
},
|
||
"execution_count": 8,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"fc_data = pd.read_excel('fantacalcio/Quotazioni_Fantacalcio.xlsx', 'Tutti', header = 1)\n",
|
||
"\n",
|
||
"fc_players = fc_data [['Id', 'R', 'Nome', 'Squadra']]\n",
|
||
"\n",
|
||
"fc_players = fc_players.rename(columns = {'Id' : 'id', 'R': 'r', 'Nome' : 'name', 'Squadra' : 'team'})\n",
|
||
"\n",
|
||
"fc_players['surname'] = fc_players['name']\n",
|
||
"fc_players['initial'] = fc_players['name']\n",
|
||
"\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" spl = normalize_name( fc_players['name'][i].replace('\\'', '') ).split(' ')\n",
|
||
" if('.' in spl[-1]):\n",
|
||
" fc_players.loc[i, 'surname'] = spl[-2]\n",
|
||
" fc_players.loc[i, 'initial'] = spl[-1][0]\n",
|
||
" else:\n",
|
||
" fc_players.loc[i, 'surname'] = spl[-1]\n",
|
||
" fc_players.loc[i, 'initial'] = ''\n",
|
||
" \n",
|
||
"fc_players\n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d944c720",
|
||
"metadata": {},
|
||
"source": [
|
||
"Associate players from Fantacalcio list to ID for FBref data."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 9,
|
||
"id": "9c50e4b5",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"fc_players['fb_ID'] = fc_players['id']\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" fc_players.loc[i, 'fb_ID'] = -1\n",
|
||
" \n",
|
||
" for j in range(players.shape[0]):\n",
|
||
" if(fc_players['team'][i].lower() in players['team'][j].lower()):\n",
|
||
" if(fc_players['surname'][i].lower() == players['surname'][j].lower()): \n",
|
||
" # if(fc_players['initial'][i] == '' or fc_players['initial'][i].lower() == players['initial'][j].lower()):\n",
|
||
" if((fc_players['r'][i] == 'P') == (j >= keepers_ID)): # check wether they're a goalkeeper for both FBREF and Fantacalcio\n",
|
||
" fc_players.loc[i, 'fb_ID'] = j\n",
|
||
" \n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "4e60fd2e",
|
||
"metadata": {},
|
||
"source": [
|
||
"Print players for which the association failed.\n",
|
||
"\n",
|
||
"Most of them are players who didn't play a single Serie A game this season with their team. If that is the case, and there is data from their previous team, that is taken here.\n",
|
||
"\n",
|
||
"Others are ones for which the FBRef surname doesn't correspond to Fantacalcio one.\n",
|
||
"\n",
|
||
"\n",
|
||
"For example, Cabral is Arthur for FBref.\n",
|
||
"\n",
|
||
"Correction is made in the name_fix code above."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 11,
|
||
"id": "18f6c5f2",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Sportiello not found\n",
|
||
"Mirante not found\n",
|
||
"Sepe not found\n",
|
||
"Leali not found\n",
|
||
"Lamanna not found\n",
|
||
"Sommariva not found\n",
|
||
"Pegolo not found\n",
|
||
"Perilli not found\n",
|
||
"Padelli not found\n",
|
||
"Scuffet not found\n",
|
||
"Gollini not found\n",
|
||
"Audero not found\n",
|
||
"Di Gennaro not found\n",
|
||
"Pinsoglio not found\n",
|
||
"Aresti not found\n",
|
||
"Fiorillo not found\n",
|
||
"Rossi F. not found\n",
|
||
"Costil not found\n",
|
||
"Ravaglia F. not found\n",
|
||
"Frattali not found\n",
|
||
"Contini not found\n",
|
||
"Brancolini not found\n",
|
||
"Berardi A. not found\n",
|
||
"Gemello not found\n",
|
||
"Boer not found\n",
|
||
"Bagnolini not found\n",
|
||
"Svilar not found\n",
|
||
"Martinelli T. not found\n",
|
||
"Popa not found\n",
|
||
"Stubljar not found\n",
|
||
"Gori not found\n",
|
||
"Borbei not found\n",
|
||
"Okoye not found\n",
|
||
"Mandas not found\n",
|
||
"Pavard not found\n",
|
||
"Kristensen not found\n",
|
||
"Natan not found\n",
|
||
"Mina not found\n",
|
||
"Hateboer not found\n",
|
||
"Masina not found\n",
|
||
"Djidji not found\n",
|
||
"Tressoldi not found\n",
|
||
"Ehizibue not found\n",
|
||
"Vogliacco not found\n",
|
||
"Ferrari G. not found\n",
|
||
"Venuti not found\n",
|
||
"Gunter not found\n",
|
||
"Soumaoro not found\n",
|
||
"Zanoli not found\n",
|
||
"Sazonov not found\n",
|
||
"Rugani not found\n",
|
||
"De Sciglio not found\n",
|
||
"Bonifazi not found\n",
|
||
"Kumbulla not found\n",
|
||
"Daniliuc not found\n",
|
||
"Haps not found\n",
|
||
"Cittadini not found\n",
|
||
"Kristensen T. not found\n",
|
||
"Dermaku not found\n",
|
||
"Tonelli not found\n",
|
||
"Capradossi not found\n",
|
||
"Bettella not found\n",
|
||
"Amey not found\n",
|
||
"Gila not found\n",
|
||
"Bronn not found\n",
|
||
"Guarino not found\n",
|
||
"Smajlovic not found\n",
|
||
"Matturro not found\n",
|
||
"N'guessan not found\n",
|
||
"Mateus Lusuardi not found\n",
|
||
"Kalaj not found\n",
|
||
"Pierozzi not found\n",
|
||
"Huijsen not found\n",
|
||
"Bonfanti not found\n",
|
||
"Pellegrino not found\n",
|
||
"Comuzzo not found\n",
|
||
"Lindstrom not found\n",
|
||
"Ikone' not found\n",
|
||
"Bennacer not found\n",
|
||
"Castrovilli not found\n",
|
||
"Klaassen not found\n",
|
||
"Messias not found\n",
|
||
"Reinier not found\n",
|
||
"Cajuste not found\n",
|
||
"Mancosu not found\n",
|
||
"Oudin not found\n",
|
||
"Machin not found\n",
|
||
"Iling Junior not found\n",
|
||
"Bourabia not found\n",
|
||
"Saelemaekers not found\n",
|
||
"Maldini not found\n",
|
||
"Ranocchia F. not found\n",
|
||
"Tchatchoua not found\n",
|
||
"Romero L. not found\n",
|
||
"Basic not found\n",
|
||
"Gaetano not found\n",
|
||
"Jagiello not found\n",
|
||
"Obiang not found\n",
|
||
"Akpa Akpro not found\n",
|
||
"Hrustic not found\n",
|
||
"Camara E. not found\n",
|
||
"Viola not found\n",
|
||
"Lulic K. not found\n",
|
||
"Rog not found\n",
|
||
"Nicolussi Caviglia not found\n",
|
||
"Demme not found\n",
|
||
"Pafundi not found\n",
|
||
"Adli not found\n",
|
||
"Faticanti not found\n",
|
||
"Belardinelli not found\n",
|
||
"Lipani not found\n",
|
||
"Joselito not found\n",
|
||
"Legowski not found\n",
|
||
"Ibrahimovic A. not found\n",
|
||
"Sanchez not found\n",
|
||
"Toure' E. not found\n",
|
||
"Lapadula not found\n",
|
||
"Abraham not found\n",
|
||
"Deulofeu not found\n",
|
||
"Henry not found\n",
|
||
"Luvumbo not found\n",
|
||
"Brenner not found\n",
|
||
"Davis K. not found\n",
|
||
"Sansone not found\n",
|
||
"Jovane not found\n",
|
||
"Alvarez A. not found\n",
|
||
"Cruz not found\n",
|
||
"Puscas not found\n",
|
||
"Ake' M. not found\n",
|
||
"Braaf not found\n",
|
||
"Kallon not found\n",
|
||
"Kaio Jorge not found\n",
|
||
"Vivaldo not found\n",
|
||
"Bidaoui not found\n",
|
||
"Corfitzen not found\n",
|
||
"Stewart not found\n",
|
||
"Yildiz not found\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"exceptions = ['pellegrini', 'bastoni'] # exceptions for such players that have the same surname as others (Berardi A., Luca Pellegrini)\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" if(fc_players['fb_ID'][i] == -1):\n",
|
||
" found = False\n",
|
||
" for j in range(players.shape[0]):\n",
|
||
" if(fc_players['surname'][i].lower() == players['surname'][j].lower()):\n",
|
||
" if(not(players['surname'][j].lower() in exceptions)):\n",
|
||
" if((fc_players['r'][i] == 'P') == (j >= keepers_ID)):\n",
|
||
" fc_players.loc[i, 'fb_ID']= j\n",
|
||
" found = True\n",
|
||
" if(found):\n",
|
||
" print(fc_players['name'][i] + ' from previous team stats')\n",
|
||
" else:\n",
|
||
" print(fc_players['name'][i] + ' not found')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 12,
|
||
"id": "3b4a36af",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>id</th>\n",
|
||
" <th>r</th>\n",
|
||
" <th>name</th>\n",
|
||
" <th>team</th>\n",
|
||
" <th>surname</th>\n",
|
||
" <th>initial</th>\n",
|
||
" <th>fb_ID</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>2428</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td></td>\n",
|
||
" <td>452</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>453</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td></td>\n",
|
||
" <td>454</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>572</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td></td>\n",
|
||
" <td>440</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>2814</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td>Lazio</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td></td>\n",
|
||
" <td>448</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>4312</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td>Milan</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td></td>\n",
|
||
" <td>438</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>534</th>\n",
|
||
" <td>6395</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Shpendi S.</td>\n",
|
||
" <td>Empoli</td>\n",
|
||
" <td>Shpendi</td>\n",
|
||
" <td>S</td>\n",
|
||
" <td>361</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>535</th>\n",
|
||
" <td>6418</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td></td>\n",
|
||
" <td>55</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>536</th>\n",
|
||
" <td>6419</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>537</th>\n",
|
||
" <td>6427</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td>Salernitana</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>538</th>\n",
|
||
" <td>6434</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>539 rows × 7 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" id r name team surname initial fb_ID\n",
|
||
"0 2428 P Sommer Inter Sommer 452\n",
|
||
"1 453 P Szczesny Juventus Szczesny 454\n",
|
||
"2 572 P Meret Napoli Meret 440\n",
|
||
"3 2814 P Provedel Lazio Provedel 448\n",
|
||
"4 4312 P Maignan Milan Maignan 438\n",
|
||
".. ... .. ... ... ... ... ...\n",
|
||
"534 6395 A Shpendi S. Empoli Shpendi S 361\n",
|
||
"535 6418 A Burnete Lecce Burnete 55\n",
|
||
"536 6419 A Corfitzen Lecce Corfitzen -1\n",
|
||
"537 6427 A Stewart Salernitana Stewart -1\n",
|
||
"538 6434 A Yildiz Juventus Yildiz -1\n",
|
||
"\n",
|
||
"[539 rows x 7 columns]"
|
||
]
|
||
},
|
||
"execution_count": 12,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"fc_players"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "f06afbb6",
|
||
"metadata": {},
|
||
"source": [
|
||
"Populate players dataset with stats from FBref, for outfield players and goalkeepers"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 13,
|
||
"id": "1d73a312",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\2053436513.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy] = 0\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"#Data for Outfield players\n",
|
||
"columns_to_copy = outfield_players.columns[4:]\n",
|
||
"\n",
|
||
"fc_players[columns_to_copy] = 0\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" if(fc_players['fb_ID'][i] != -1 and fc_players['r'][i] != 'P'):\n",
|
||
" for j in range(columns_to_copy.shape[0]):\n",
|
||
" #fc_players[columns_to_copy[j]][i] = outfield_players[columns_to_copy[j]][fc_players['fb_ID'][i]]\n",
|
||
" fc_players.loc[i, columns_to_copy[j]] = outfield_players.loc[fc_players['fb_ID'][i], columns_to_copy[j]]\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 14,
|
||
"id": "7acb93e3",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"Index(['age', 'birth_year', 'gk_games', 'gk_games_starts', 'gk_minutes',\n",
|
||
" 'gk_goals_against', 'gk_goals_against_per90',\n",
|
||
" 'gk_shots_on_target_against', 'gk_saves', 'gk_save_pct', 'gk_wins',\n",
|
||
" 'gk_ties', 'gk_losses', 'gk_clean_sheets', 'gk_clean_sheets_pct',\n",
|
||
" 'gk_pens_att', 'gk_pens_allowed', 'gk_pens_saved', 'gk_pens_missed',\n",
|
||
" 'minutes_90s', 'gk_free_kick_goals_against',\n",
|
||
" 'gk_corner_kick_goals_against', 'gk_own_goals_against', 'gk_psxg',\n",
|
||
" 'gk_psnpxg_per_shot_on_target_against', 'gk_psxg_net',\n",
|
||
" 'gk_psxg_net_per90', 'gk_passes_completed_launched',\n",
|
||
" 'gk_passes_launched', 'gk_passes_pct_launched', 'gk_passes',\n",
|
||
" 'gk_passes_throws', 'gk_pct_passes_launched', 'gk_passes_length_avg',\n",
|
||
" 'gk_goal_kicks', 'gk_pct_goal_kicks_launched',\n",
|
||
" 'gk_goal_kick_length_avg', 'gk_crosses', 'gk_crosses_stopped',\n",
|
||
" 'gk_crosses_stopped_pct', 'gk_def_actions_outside_pen_area',\n",
|
||
" 'gk_def_actions_outside_pen_area_per90', 'gk_avg_distance_def_actions'],\n",
|
||
" dtype='object')"
|
||
]
|
||
},
|
||
"execution_count": 14,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"keeper_players.columns[4:]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 15,
|
||
"id": "eb9127a9",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_2156\\127446819.py:4: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
|
||
" fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"#Data for Keepers\n",
|
||
"columns_to_copy = keeper_players.columns[4:]\n",
|
||
"\n",
|
||
"fc_players[columns_to_copy[2:]] = 0 # add columns but do not override age and birth_year\n",
|
||
"\n",
|
||
"delta_k = outfield_players.shape[0]\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" if(fc_players['fb_ID'][i] != -1 and fc_players['r'][i] == 'P'):\n",
|
||
" for j in range(columns_to_copy.shape[0]):\n",
|
||
" #fc_players[columns_to_copy[j]][i] = keeper_players[columns_to_copy[j]][fc_players['fb_ID'][i] - delta_k]\n",
|
||
" fc_players.loc[i, columns_to_copy[j]] = keeper_players.loc[fc_players['fb_ID'][i] - delta_k, columns_to_copy[j]]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 16,
|
||
"id": "da977789",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>id</th>\n",
|
||
" <th>r</th>\n",
|
||
" <th>name</th>\n",
|
||
" <th>team</th>\n",
|
||
" <th>surname</th>\n",
|
||
" <th>initial</th>\n",
|
||
" <th>fb_ID</th>\n",
|
||
" <th>age</th>\n",
|
||
" <th>birth_year</th>\n",
|
||
" <th>games</th>\n",
|
||
" <th>...</th>\n",
|
||
" <th>gk_passes_length_avg</th>\n",
|
||
" <th>gk_goal_kicks</th>\n",
|
||
" <th>gk_pct_goal_kicks_launched</th>\n",
|
||
" <th>gk_goal_kick_length_avg</th>\n",
|
||
" <th>gk_crosses</th>\n",
|
||
" <th>gk_crosses_stopped</th>\n",
|
||
" <th>gk_crosses_stopped_pct</th>\n",
|
||
" <th>gk_def_actions_outside_pen_area</th>\n",
|
||
" <th>gk_def_actions_outside_pen_area_per90</th>\n",
|
||
" <th>gk_avg_distance_def_actions</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>2428</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td></td>\n",
|
||
" <td>452</td>\n",
|
||
" <td>34-278</td>\n",
|
||
" <td>1988</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>30.8</td>\n",
|
||
" <td>29</td>\n",
|
||
" <td>20.7</td>\n",
|
||
" <td>28.3</td>\n",
|
||
" <td>41</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4.9</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>6.5</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>453</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td></td>\n",
|
||
" <td>454</td>\n",
|
||
" <td>33-156</td>\n",
|
||
" <td>1990</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>33.1</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>66.7</td>\n",
|
||
" <td>52.0</td>\n",
|
||
" <td>33</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>9.6</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>572</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td></td>\n",
|
||
" <td>440</td>\n",
|
||
" <td>26-183</td>\n",
|
||
" <td>1997</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>24.7</td>\n",
|
||
" <td>11</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>20.4</td>\n",
|
||
" <td>27</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3.7</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>1.75</td>\n",
|
||
" <td>18.2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>2814</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td>Lazio</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td></td>\n",
|
||
" <td>448</td>\n",
|
||
" <td>29-188</td>\n",
|
||
" <td>1994</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>26.4</td>\n",
|
||
" <td>15</td>\n",
|
||
" <td>20.0</td>\n",
|
||
" <td>27.9</td>\n",
|
||
" <td>48</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4.2</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>1.50</td>\n",
|
||
" <td>15.7</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>4312</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td>Milan</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td></td>\n",
|
||
" <td>438</td>\n",
|
||
" <td>28-080</td>\n",
|
||
" <td>1995</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>29.2</td>\n",
|
||
" <td>23</td>\n",
|
||
" <td>60.9</td>\n",
|
||
" <td>47.0</td>\n",
|
||
" <td>52</td>\n",
|
||
" <td>12</td>\n",
|
||
" <td>23.1</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>0.75</td>\n",
|
||
" <td>9.8</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>534</th>\n",
|
||
" <td>6395</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Shpendi S.</td>\n",
|
||
" <td>Empoli</td>\n",
|
||
" <td>Shpendi</td>\n",
|
||
" <td>S</td>\n",
|
||
" <td>361</td>\n",
|
||
" <td>20-125</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>535</th>\n",
|
||
" <td>6418</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td></td>\n",
|
||
" <td>55</td>\n",
|
||
" <td>19-233</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>536</th>\n",
|
||
" <td>6419</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>537</th>\n",
|
||
" <td>6427</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td>Salernitana</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>538</th>\n",
|
||
" <td>6434</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>539 rows × 158 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" id r name team surname initial fb_ID age \\\n",
|
||
"0 2428 P Sommer Inter Sommer 452 34-278 \n",
|
||
"1 453 P Szczesny Juventus Szczesny 454 33-156 \n",
|
||
"2 572 P Meret Napoli Meret 440 26-183 \n",
|
||
"3 2814 P Provedel Lazio Provedel 448 29-188 \n",
|
||
"4 4312 P Maignan Milan Maignan 438 28-080 \n",
|
||
".. ... .. ... ... ... ... ... ... \n",
|
||
"534 6395 A Shpendi S. Empoli Shpendi S 361 20-125 \n",
|
||
"535 6418 A Burnete Lecce Burnete 55 19-233 \n",
|
||
"536 6419 A Corfitzen Lecce Corfitzen -1 0 \n",
|
||
"537 6427 A Stewart Salernitana Stewart -1 0 \n",
|
||
"538 6434 A Yildiz Juventus Yildiz -1 0 \n",
|
||
"\n",
|
||
" birth_year games ... gk_passes_length_avg gk_goal_kicks \\\n",
|
||
"0 1988 0 ... 30.8 29 \n",
|
||
"1 1990 0 ... 33.1 6 \n",
|
||
"2 1997 0 ... 24.7 11 \n",
|
||
"3 1994 0 ... 26.4 15 \n",
|
||
"4 1995 0 ... 29.2 23 \n",
|
||
".. ... ... ... ... ... \n",
|
||
"534 2003 3 ... 0.0 0 \n",
|
||
"535 2004 1 ... 0.0 0 \n",
|
||
"536 0 0 ... 0.0 0 \n",
|
||
"537 0 0 ... 0.0 0 \n",
|
||
"538 0 0 ... 0.0 0 \n",
|
||
"\n",
|
||
" gk_pct_goal_kicks_launched gk_goal_kick_length_avg gk_crosses \\\n",
|
||
"0 20.7 28.3 41 \n",
|
||
"1 66.7 52.0 33 \n",
|
||
"2 0.0 20.4 27 \n",
|
||
"3 20.0 27.9 48 \n",
|
||
"4 60.9 47.0 52 \n",
|
||
".. ... ... ... \n",
|
||
"534 0.0 0.0 0 \n",
|
||
"535 0.0 0.0 0 \n",
|
||
"536 0.0 0.0 0 \n",
|
||
"537 0.0 0.0 0 \n",
|
||
"538 0.0 0.0 0 \n",
|
||
"\n",
|
||
" gk_crosses_stopped gk_crosses_stopped_pct \\\n",
|
||
"0 2 4.9 \n",
|
||
"1 1 3.0 \n",
|
||
"2 1 3.7 \n",
|
||
"3 2 4.2 \n",
|
||
"4 12 23.1 \n",
|
||
".. ... ... \n",
|
||
"534 0 0.0 \n",
|
||
"535 0 0.0 \n",
|
||
"536 0 0.0 \n",
|
||
"537 0 0.0 \n",
|
||
"538 0 0.0 \n",
|
||
"\n",
|
||
" gk_def_actions_outside_pen_area gk_def_actions_outside_pen_area_per90 \\\n",
|
||
"0 0 0.00 \n",
|
||
"1 0 0.00 \n",
|
||
"2 7 1.75 \n",
|
||
"3 6 1.50 \n",
|
||
"4 3 0.75 \n",
|
||
".. ... ... \n",
|
||
"534 0 0.00 \n",
|
||
"535 0 0.00 \n",
|
||
"536 0 0.00 \n",
|
||
"537 0 0.00 \n",
|
||
"538 0 0.00 \n",
|
||
"\n",
|
||
" gk_avg_distance_def_actions \n",
|
||
"0 6.5 \n",
|
||
"1 9.6 \n",
|
||
"2 18.2 \n",
|
||
"3 15.7 \n",
|
||
"4 9.8 \n",
|
||
".. ... \n",
|
||
"534 0.0 \n",
|
||
"535 0.0 \n",
|
||
"536 0.0 \n",
|
||
"537 0.0 \n",
|
||
"538 0.0 \n",
|
||
"\n",
|
||
"[539 rows x 158 columns]"
|
||
]
|
||
},
|
||
"execution_count": 16,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"fc_players"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "81a17f84",
|
||
"metadata": {},
|
||
"source": [
|
||
"Load votes database, to add data to players database (mean vote and its standard deviation)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 17,
|
||
"id": "6a0e43cd",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import numpy as np\n",
|
||
"\n",
|
||
"votes = pd.read_excel('mid_outputs/players_votes.xlsx', index_col = 0)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "6c1b733a",
|
||
"metadata": {},
|
||
"source": [
|
||
"Compute the average Serie A Goal Keeper mean vote and vote std"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 18,
|
||
"id": "61fac91a",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"vote_avg 6.090909\n",
|
||
"vote_std 0.360285\n",
|
||
"dtype: float64\n"
|
||
]
|
||
},
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>vote_avg</th>\n",
|
||
" <th>vote_std</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>6.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>6.375000</td>\n",
|
||
" <td>0.414578</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>5.875000</td>\n",
|
||
" <td>0.544862</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>6.125000</td>\n",
|
||
" <td>0.216506</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.353553</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>6.500000</td>\n",
|
||
" <td>0.707107</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>6.625000</td>\n",
|
||
" <td>0.414578</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>5.625000</td>\n",
|
||
" <td>0.414578</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>5.875000</td>\n",
|
||
" <td>0.819680</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>6.500000</td>\n",
|
||
" <td>0.353553</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>5.875000</td>\n",
|
||
" <td>0.216506</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>6.125000</td>\n",
|
||
" <td>0.649519</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>6.333333</td>\n",
|
||
" <td>0.849837</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>5.833333</td>\n",
|
||
" <td>0.235702</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>6.333333</td>\n",
|
||
" <td>0.235702</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>20</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.500000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>21</th>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" vote_avg vote_std\n",
|
||
"0 6.000000 0.000000\n",
|
||
"1 6.750000 0.250000\n",
|
||
"2 5.750000 0.250000\n",
|
||
"3 6.375000 0.414578\n",
|
||
"4 6.000000 0.000000\n",
|
||
"5 5.875000 0.544862\n",
|
||
"6 6.125000 0.216506\n",
|
||
"7 6.000000 0.353553\n",
|
||
"8 6.500000 0.707107\n",
|
||
"9 6.625000 0.414578\n",
|
||
"10 5.625000 0.414578\n",
|
||
"11 5.750000 0.250000\n",
|
||
"12 5.875000 0.819680\n",
|
||
"13 6.500000 0.353553\n",
|
||
"14 5.875000 0.216506\n",
|
||
"15 6.125000 0.649519\n",
|
||
"16 6.333333 0.849837\n",
|
||
"17 5.833333 0.235702\n",
|
||
"18 6.333333 0.235702\n",
|
||
"19 6.000000 0.000000\n",
|
||
"20 6.000000 0.500000\n",
|
||
"21 5.750000 0.250000"
|
||
]
|
||
},
|
||
"execution_count": 18,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"min_votes = 3 # TO BE UPDATED WHEN SERIE A HAS MORE CALENDAR WEEKS PLAYED\n",
|
||
"\n",
|
||
"perf_df_P = pd.DataFrame(columns = ['vote_avg', 'vote_std'])\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]): \n",
|
||
" if(fc_players.loc[i]['r'] == 'P'):\n",
|
||
" v = np.array([])\n",
|
||
" for j in range(votes.shape[0]):\n",
|
||
" if(fc_players['name'][i] == votes['player'][j]):\n",
|
||
" v = np.append(v, votes['vote'][j])\n",
|
||
"\n",
|
||
" if(v.shape[0] >= min_votes - 1):\n",
|
||
" row_df = pd.DataFrame(data = [[np.mean(v), np.std(v)]], columns = perf_df_P.columns)\n",
|
||
" perf_df_P = pd.concat([perf_df_P, row_df], ignore_index = True)\n",
|
||
"\n",
|
||
"\n",
|
||
"print(perf_df_P.mean())\n",
|
||
"\n",
|
||
"perf_df_P\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "dbb344e2",
|
||
"metadata": {},
|
||
"source": [
|
||
"Add to players data their mean vote (and its standard deviation).\n",
|
||
"\n",
|
||
"For players who don't have a minimum amount of games, more data to reach this value is computed, according to the average Serie A player vote (and std). For goalkeepers, this values are different.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 19,
|
||
"id": "c9312080",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>vote_avg</th>\n",
|
||
" <th>vote_std</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>6.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>6.375000</td>\n",
|
||
" <td>0.414578</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>534</th>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>535</th>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>536</th>\n",
|
||
" <td>5.799850</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>537</th>\n",
|
||
" <td>6.447669</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>538</th>\n",
|
||
" <td>6.437600</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>539 rows × 2 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" vote_avg vote_std\n",
|
||
"0 6.000000 0.000000\n",
|
||
"1 6.750000 0.250000\n",
|
||
"2 5.750000 0.250000\n",
|
||
"3 6.375000 0.414578\n",
|
||
"4 6.000000 0.000000\n",
|
||
".. ... ...\n",
|
||
"534 5.750000 0.250000\n",
|
||
"535 6.000000 0.000000\n",
|
||
"536 5.799850 0.000000\n",
|
||
"537 6.447669 0.000000\n",
|
||
"538 6.437600 0.000000\n",
|
||
"\n",
|
||
"[539 rows x 2 columns]"
|
||
]
|
||
},
|
||
"execution_count": 19,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"min_votes = 1 # TO BE UPDATED WHEN SERIE A HAS MORE CALENDAR WEEKS PLAYED\n",
|
||
"\n",
|
||
"#outfield players\n",
|
||
"mean_def = 6\n",
|
||
"std_def = 0.58\n",
|
||
"\n",
|
||
"#goalkeepers\n",
|
||
"mean_def_P = 6.22\n",
|
||
"std_def_P = 0.43\n",
|
||
"\n",
|
||
"\n",
|
||
"perf_df = pd.DataFrame(columns = ['vote_avg', 'vote_std'])\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" v = np.array([])\n",
|
||
" for j in range(votes.shape[0]):\n",
|
||
" if(fc_players['name'][i] == votes['player'][j]):\n",
|
||
" v = np.append(v, votes['vote'][j])\n",
|
||
" \n",
|
||
" mean_def_i = mean_def\n",
|
||
" std_def_i = std_def\n",
|
||
" \n",
|
||
" if(fc_players['r'][i] == 'P'):\n",
|
||
" mean_def_i = mean_def_P\n",
|
||
" std_def_i = std_def_P\n",
|
||
" \n",
|
||
" if(v.shape[0] < min_votes):\n",
|
||
" for k in range(min_votes - v.shape[0]):\n",
|
||
" v = np.append( v, np.random.normal(mean_def_i, std_def_i) )\n",
|
||
" \n",
|
||
" row_df = pd.DataFrame(data = [[np.mean(v), np.std(v)]], columns = perf_df.columns)\n",
|
||
" perf_df = pd.concat([perf_df, row_df], ignore_index = True)\n",
|
||
" \n",
|
||
"perf_df\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 20,
|
||
"id": "b2570ce5",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>id</th>\n",
|
||
" <th>r</th>\n",
|
||
" <th>name</th>\n",
|
||
" <th>team</th>\n",
|
||
" <th>surname</th>\n",
|
||
" <th>initial</th>\n",
|
||
" <th>fb_ID</th>\n",
|
||
" <th>age</th>\n",
|
||
" <th>birth_year</th>\n",
|
||
" <th>games</th>\n",
|
||
" <th>...</th>\n",
|
||
" <th>gk_pct_goal_kicks_launched</th>\n",
|
||
" <th>gk_goal_kick_length_avg</th>\n",
|
||
" <th>gk_crosses</th>\n",
|
||
" <th>gk_crosses_stopped</th>\n",
|
||
" <th>gk_crosses_stopped_pct</th>\n",
|
||
" <th>gk_def_actions_outside_pen_area</th>\n",
|
||
" <th>gk_def_actions_outside_pen_area_per90</th>\n",
|
||
" <th>gk_avg_distance_def_actions</th>\n",
|
||
" <th>vote_avg</th>\n",
|
||
" <th>vote_std</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>2428</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td></td>\n",
|
||
" <td>452</td>\n",
|
||
" <td>34-278</td>\n",
|
||
" <td>1988</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>20.7</td>\n",
|
||
" <td>28.3</td>\n",
|
||
" <td>41</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4.9</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>6.5</td>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>453</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td></td>\n",
|
||
" <td>454</td>\n",
|
||
" <td>33-156</td>\n",
|
||
" <td>1990</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>66.7</td>\n",
|
||
" <td>52.0</td>\n",
|
||
" <td>33</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>9.6</td>\n",
|
||
" <td>6.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>572</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td></td>\n",
|
||
" <td>440</td>\n",
|
||
" <td>26-183</td>\n",
|
||
" <td>1997</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>20.4</td>\n",
|
||
" <td>27</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3.7</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>1.75</td>\n",
|
||
" <td>18.2</td>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>2814</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td>Lazio</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td></td>\n",
|
||
" <td>448</td>\n",
|
||
" <td>29-188</td>\n",
|
||
" <td>1994</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>20.0</td>\n",
|
||
" <td>27.9</td>\n",
|
||
" <td>48</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4.2</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>1.50</td>\n",
|
||
" <td>15.7</td>\n",
|
||
" <td>6.375000</td>\n",
|
||
" <td>0.414578</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>4312</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td>Milan</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td></td>\n",
|
||
" <td>438</td>\n",
|
||
" <td>28-080</td>\n",
|
||
" <td>1995</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>60.9</td>\n",
|
||
" <td>47.0</td>\n",
|
||
" <td>52</td>\n",
|
||
" <td>12</td>\n",
|
||
" <td>23.1</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>0.75</td>\n",
|
||
" <td>9.8</td>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>534</th>\n",
|
||
" <td>6395</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Shpendi S.</td>\n",
|
||
" <td>Empoli</td>\n",
|
||
" <td>Shpendi</td>\n",
|
||
" <td>S</td>\n",
|
||
" <td>361</td>\n",
|
||
" <td>20-125</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>535</th>\n",
|
||
" <td>6418</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td></td>\n",
|
||
" <td>55</td>\n",
|
||
" <td>19-233</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>536</th>\n",
|
||
" <td>6419</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>5.799850</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>537</th>\n",
|
||
" <td>6427</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td>Salernitana</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>6.447669</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>538</th>\n",
|
||
" <td>6434</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>6.437600</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>539 rows × 160 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" id r name team surname initial fb_ID age \\\n",
|
||
"0 2428 P Sommer Inter Sommer 452 34-278 \n",
|
||
"1 453 P Szczesny Juventus Szczesny 454 33-156 \n",
|
||
"2 572 P Meret Napoli Meret 440 26-183 \n",
|
||
"3 2814 P Provedel Lazio Provedel 448 29-188 \n",
|
||
"4 4312 P Maignan Milan Maignan 438 28-080 \n",
|
||
".. ... .. ... ... ... ... ... ... \n",
|
||
"534 6395 A Shpendi S. Empoli Shpendi S 361 20-125 \n",
|
||
"535 6418 A Burnete Lecce Burnete 55 19-233 \n",
|
||
"536 6419 A Corfitzen Lecce Corfitzen -1 0 \n",
|
||
"537 6427 A Stewart Salernitana Stewart -1 0 \n",
|
||
"538 6434 A Yildiz Juventus Yildiz -1 0 \n",
|
||
"\n",
|
||
" birth_year games ... gk_pct_goal_kicks_launched \\\n",
|
||
"0 1988 0 ... 20.7 \n",
|
||
"1 1990 0 ... 66.7 \n",
|
||
"2 1997 0 ... 0.0 \n",
|
||
"3 1994 0 ... 20.0 \n",
|
||
"4 1995 0 ... 60.9 \n",
|
||
".. ... ... ... ... \n",
|
||
"534 2003 3 ... 0.0 \n",
|
||
"535 2004 1 ... 0.0 \n",
|
||
"536 0 0 ... 0.0 \n",
|
||
"537 0 0 ... 0.0 \n",
|
||
"538 0 0 ... 0.0 \n",
|
||
"\n",
|
||
" gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n",
|
||
"0 28.3 41 2 \n",
|
||
"1 52.0 33 1 \n",
|
||
"2 20.4 27 1 \n",
|
||
"3 27.9 48 2 \n",
|
||
"4 47.0 52 12 \n",
|
||
".. ... ... ... \n",
|
||
"534 0.0 0 0 \n",
|
||
"535 0.0 0 0 \n",
|
||
"536 0.0 0 0 \n",
|
||
"537 0.0 0 0 \n",
|
||
"538 0.0 0 0 \n",
|
||
"\n",
|
||
" gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n",
|
||
"0 4.9 0 \n",
|
||
"1 3.0 0 \n",
|
||
"2 3.7 7 \n",
|
||
"3 4.2 6 \n",
|
||
"4 23.1 3 \n",
|
||
".. ... ... \n",
|
||
"534 0.0 0 \n",
|
||
"535 0.0 0 \n",
|
||
"536 0.0 0 \n",
|
||
"537 0.0 0 \n",
|
||
"538 0.0 0 \n",
|
||
"\n",
|
||
" gk_def_actions_outside_pen_area_per90 gk_avg_distance_def_actions \\\n",
|
||
"0 0.00 6.5 \n",
|
||
"1 0.00 9.6 \n",
|
||
"2 1.75 18.2 \n",
|
||
"3 1.50 15.7 \n",
|
||
"4 0.75 9.8 \n",
|
||
".. ... ... \n",
|
||
"534 0.00 0.0 \n",
|
||
"535 0.00 0.0 \n",
|
||
"536 0.00 0.0 \n",
|
||
"537 0.00 0.0 \n",
|
||
"538 0.00 0.0 \n",
|
||
"\n",
|
||
" vote_avg vote_std \n",
|
||
"0 6.000000 0.000000 \n",
|
||
"1 6.750000 0.250000 \n",
|
||
"2 5.750000 0.250000 \n",
|
||
"3 6.375000 0.414578 \n",
|
||
"4 6.000000 0.000000 \n",
|
||
".. ... ... \n",
|
||
"534 5.750000 0.250000 \n",
|
||
"535 6.000000 0.000000 \n",
|
||
"536 5.799850 0.000000 \n",
|
||
"537 6.447669 0.000000 \n",
|
||
"538 6.437600 0.000000 \n",
|
||
"\n",
|
||
"[539 rows x 160 columns]"
|
||
]
|
||
},
|
||
"execution_count": 20,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"fc_players = pd.concat([fc_players, perf_df], axis = 1)\n",
|
||
"\n",
|
||
"fc_players"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 21,
|
||
"id": "f7620abe",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"'gk_games'"
|
||
]
|
||
},
|
||
"execution_count": 21,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"GK_GAMES_COLUMN = 118\n",
|
||
"\n",
|
||
"fc_players.columns[GK_GAMES_COLUMN]\n",
|
||
"\n",
|
||
"# check it if is 'gk_games'"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "c550c370",
|
||
"metadata": {},
|
||
"source": [
|
||
"For goalkeepers who didn't play a miminum amount of games, data is weightly averaged with one of the main goalkeeper of their same team."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 22,
|
||
"id": "700b7a7d",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Sportiello, 0.0\n",
|
||
"Mirante, 0.0\n",
|
||
"Sepe, 0.0\n",
|
||
"Leali, 0.0\n",
|
||
"Lamanna, 0.0\n",
|
||
"Sommariva, 0.0\n",
|
||
"Pegolo, 0.0\n",
|
||
"Perilli, 0.0\n",
|
||
"Padelli, 0.0\n",
|
||
"Scuffet, 0.0\n",
|
||
"Gollini, 0.0\n",
|
||
"Audero, 0.0\n",
|
||
"Di Gennaro, 0.0\n",
|
||
"Pinsoglio, 0.0\n",
|
||
"Aresti, 0.0\n",
|
||
"Fiorillo, 0.0\n",
|
||
"Rossi F., 0.0\n",
|
||
"Costil, 0.0\n",
|
||
"Ravaglia F., 0.0\n",
|
||
"Frattali, 0.0\n",
|
||
"Contini, 0.0\n",
|
||
"Brancolini, 0.0\n",
|
||
"Berardi A., 0.0\n",
|
||
"Gemello, 0.0\n",
|
||
"Boer, 0.0\n",
|
||
"Bagnolini, 0.0\n",
|
||
"Svilar, 0.0\n",
|
||
"Martinelli T., 0.0\n",
|
||
"Popa, 0.0\n",
|
||
"Stubljar, 0.0\n",
|
||
"Gori, 0.0\n",
|
||
"Borbei, 0.0\n",
|
||
"Okoye, 0.0\n",
|
||
"Mandas, 0.0\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"min_gk_games = 1 # TO BE UPDATED WHEN SERIE A HAS MORE CALENDAR WEEKS PLAYED\n",
|
||
"\n",
|
||
"fc_players_newgk = fc_players.copy()\n",
|
||
"\n",
|
||
"columns_to_avg = fc_players.columns[GK_GAMES_COLUMN:] # from gk_games to end\n",
|
||
"\n",
|
||
"for i in range(fc_players.shape[0]):\n",
|
||
" if(fc_players['r'][i] == 'P'):\n",
|
||
" if(fc_players['gk_games'][i] < min_gk_games):\n",
|
||
" for j in range(fc_players.shape[0]):\n",
|
||
" if(fc_players['team'][i] == fc_players['team'][j] and fc_players['gk_games'][j] >= min_gk_games):\n",
|
||
" break\n",
|
||
" \n",
|
||
" weight = 1 - (min_gk_games - fc_players['gk_games'][i]) / min_gk_games\n",
|
||
" \n",
|
||
" fc_players_newgk.at[i, columns_to_avg] = fc_players.loc[i][columns_to_avg] * weight + (1 - weight) * fc_players.loc[j][columns_to_avg]\n",
|
||
" \n",
|
||
" print(fc_players['name'][i] + ', ' + str(weight))\n",
|
||
" \n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 23,
|
||
"id": "2d9eee99",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>id</th>\n",
|
||
" <th>r</th>\n",
|
||
" <th>name</th>\n",
|
||
" <th>team</th>\n",
|
||
" <th>surname</th>\n",
|
||
" <th>initial</th>\n",
|
||
" <th>fb_ID</th>\n",
|
||
" <th>age</th>\n",
|
||
" <th>birth_year</th>\n",
|
||
" <th>games</th>\n",
|
||
" <th>...</th>\n",
|
||
" <th>gk_pct_goal_kicks_launched</th>\n",
|
||
" <th>gk_goal_kick_length_avg</th>\n",
|
||
" <th>gk_crosses</th>\n",
|
||
" <th>gk_crosses_stopped</th>\n",
|
||
" <th>gk_crosses_stopped_pct</th>\n",
|
||
" <th>gk_def_actions_outside_pen_area</th>\n",
|
||
" <th>gk_def_actions_outside_pen_area_per90</th>\n",
|
||
" <th>gk_avg_distance_def_actions</th>\n",
|
||
" <th>vote_avg</th>\n",
|
||
" <th>vote_std</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>2428</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td>Inter</td>\n",
|
||
" <td>Sommer</td>\n",
|
||
" <td></td>\n",
|
||
" <td>452</td>\n",
|
||
" <td>34-278</td>\n",
|
||
" <td>1988</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>20.7</td>\n",
|
||
" <td>28.3</td>\n",
|
||
" <td>41</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4.9</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>6.5</td>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>453</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Szczesny</td>\n",
|
||
" <td></td>\n",
|
||
" <td>454</td>\n",
|
||
" <td>33-156</td>\n",
|
||
" <td>1990</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>66.7</td>\n",
|
||
" <td>52.0</td>\n",
|
||
" <td>33</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>9.6</td>\n",
|
||
" <td>6.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>572</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td>Napoli</td>\n",
|
||
" <td>Meret</td>\n",
|
||
" <td></td>\n",
|
||
" <td>440</td>\n",
|
||
" <td>26-183</td>\n",
|
||
" <td>1997</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>20.4</td>\n",
|
||
" <td>27</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>3.7</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>1.75</td>\n",
|
||
" <td>18.2</td>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>2814</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td>Lazio</td>\n",
|
||
" <td>Provedel</td>\n",
|
||
" <td></td>\n",
|
||
" <td>448</td>\n",
|
||
" <td>29-188</td>\n",
|
||
" <td>1994</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>20.0</td>\n",
|
||
" <td>27.9</td>\n",
|
||
" <td>48</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>4.2</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>1.50</td>\n",
|
||
" <td>15.7</td>\n",
|
||
" <td>6.375000</td>\n",
|
||
" <td>0.414578</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>4312</td>\n",
|
||
" <td>P</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td>Milan</td>\n",
|
||
" <td>Maignan</td>\n",
|
||
" <td></td>\n",
|
||
" <td>438</td>\n",
|
||
" <td>28-080</td>\n",
|
||
" <td>1995</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>60.9</td>\n",
|
||
" <td>47.0</td>\n",
|
||
" <td>52</td>\n",
|
||
" <td>12</td>\n",
|
||
" <td>23.1</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>0.75</td>\n",
|
||
" <td>9.8</td>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>...</th>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>...</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>534</th>\n",
|
||
" <td>6395</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Shpendi S.</td>\n",
|
||
" <td>Empoli</td>\n",
|
||
" <td>Shpendi</td>\n",
|
||
" <td>S</td>\n",
|
||
" <td>361</td>\n",
|
||
" <td>20-125</td>\n",
|
||
" <td>2003</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>5.750000</td>\n",
|
||
" <td>0.250000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>535</th>\n",
|
||
" <td>6418</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Burnete</td>\n",
|
||
" <td></td>\n",
|
||
" <td>55</td>\n",
|
||
" <td>19-233</td>\n",
|
||
" <td>2004</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>6.000000</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>536</th>\n",
|
||
" <td>6419</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td>Lecce</td>\n",
|
||
" <td>Corfitzen</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>5.799850</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>537</th>\n",
|
||
" <td>6427</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td>Salernitana</td>\n",
|
||
" <td>Stewart</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>6.447669</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>538</th>\n",
|
||
" <td>6434</td>\n",
|
||
" <td>A</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td>Juventus</td>\n",
|
||
" <td>Yildiz</td>\n",
|
||
" <td></td>\n",
|
||
" <td>-1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0.00</td>\n",
|
||
" <td>0.0</td>\n",
|
||
" <td>6.437600</td>\n",
|
||
" <td>0.000000</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>539 rows × 160 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" id r name team surname initial fb_ID age \\\n",
|
||
"0 2428 P Sommer Inter Sommer 452 34-278 \n",
|
||
"1 453 P Szczesny Juventus Szczesny 454 33-156 \n",
|
||
"2 572 P Meret Napoli Meret 440 26-183 \n",
|
||
"3 2814 P Provedel Lazio Provedel 448 29-188 \n",
|
||
"4 4312 P Maignan Milan Maignan 438 28-080 \n",
|
||
".. ... .. ... ... ... ... ... ... \n",
|
||
"534 6395 A Shpendi S. Empoli Shpendi S 361 20-125 \n",
|
||
"535 6418 A Burnete Lecce Burnete 55 19-233 \n",
|
||
"536 6419 A Corfitzen Lecce Corfitzen -1 0 \n",
|
||
"537 6427 A Stewart Salernitana Stewart -1 0 \n",
|
||
"538 6434 A Yildiz Juventus Yildiz -1 0 \n",
|
||
"\n",
|
||
" birth_year games ... gk_pct_goal_kicks_launched \\\n",
|
||
"0 1988 0 ... 20.7 \n",
|
||
"1 1990 0 ... 66.7 \n",
|
||
"2 1997 0 ... 0.0 \n",
|
||
"3 1994 0 ... 20.0 \n",
|
||
"4 1995 0 ... 60.9 \n",
|
||
".. ... ... ... ... \n",
|
||
"534 2003 3 ... 0.0 \n",
|
||
"535 2004 1 ... 0.0 \n",
|
||
"536 0 0 ... 0.0 \n",
|
||
"537 0 0 ... 0.0 \n",
|
||
"538 0 0 ... 0.0 \n",
|
||
"\n",
|
||
" gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n",
|
||
"0 28.3 41 2 \n",
|
||
"1 52.0 33 1 \n",
|
||
"2 20.4 27 1 \n",
|
||
"3 27.9 48 2 \n",
|
||
"4 47.0 52 12 \n",
|
||
".. ... ... ... \n",
|
||
"534 0.0 0 0 \n",
|
||
"535 0.0 0 0 \n",
|
||
"536 0.0 0 0 \n",
|
||
"537 0.0 0 0 \n",
|
||
"538 0.0 0 0 \n",
|
||
"\n",
|
||
" gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n",
|
||
"0 4.9 0 \n",
|
||
"1 3.0 0 \n",
|
||
"2 3.7 7 \n",
|
||
"3 4.2 6 \n",
|
||
"4 23.1 3 \n",
|
||
".. ... ... \n",
|
||
"534 0.0 0 \n",
|
||
"535 0.0 0 \n",
|
||
"536 0.0 0 \n",
|
||
"537 0.0 0 \n",
|
||
"538 0.0 0 \n",
|
||
"\n",
|
||
" gk_def_actions_outside_pen_area_per90 gk_avg_distance_def_actions \\\n",
|
||
"0 0.00 6.5 \n",
|
||
"1 0.00 9.6 \n",
|
||
"2 1.75 18.2 \n",
|
||
"3 1.50 15.7 \n",
|
||
"4 0.75 9.8 \n",
|
||
".. ... ... \n",
|
||
"534 0.00 0.0 \n",
|
||
"535 0.00 0.0 \n",
|
||
"536 0.00 0.0 \n",
|
||
"537 0.00 0.0 \n",
|
||
"538 0.00 0.0 \n",
|
||
"\n",
|
||
" vote_avg vote_std \n",
|
||
"0 6.000000 0.000000 \n",
|
||
"1 6.750000 0.250000 \n",
|
||
"2 5.750000 0.250000 \n",
|
||
"3 6.375000 0.414578 \n",
|
||
"4 6.000000 0.000000 \n",
|
||
".. ... ... \n",
|
||
"534 5.750000 0.250000 \n",
|
||
"535 6.000000 0.000000 \n",
|
||
"536 5.799850 0.000000 \n",
|
||
"537 6.447669 0.000000 \n",
|
||
"538 6.437600 0.000000 \n",
|
||
"\n",
|
||
"[539 rows x 160 columns]"
|
||
]
|
||
},
|
||
"execution_count": 23,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"fc_players = fc_players_newgk\n",
|
||
"\n",
|
||
"fc_players"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "2b13240e",
|
||
"metadata": {},
|
||
"source": [
|
||
"Save to file."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 24,
|
||
"id": "8336c025",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"fc_players.to_excel('mid_outputs/players_stats.xlsx')"
|
||
]
|
||
}
|
||
],
|
||
"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
|
||
}
|