{
"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": 100,
"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": 101,
"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": 102,
"id": "667970f6",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" player | \n",
" team | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Tammy Abraham | \n",
" Roma | \n",
"
\n",
" \n",
" | 1 | \n",
" Francesco Acerbi | \n",
" Inter | \n",
"
\n",
" \n",
" | 2 | \n",
" Yacine Adli | \n",
" Milan | \n",
"
\n",
" \n",
" | 3 | \n",
" Michel Aebischer | \n",
" Bologna | \n",
"
\n",
" \n",
" | 4 | \n",
" Felix Afena-Gyan | \n",
" Cremonese | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 551 | \n",
" Ciprian Tătărușanu | \n",
" Milan | \n",
"
\n",
" \n",
" | 552 | \n",
" Pietro Terracciano | \n",
" Fiorentina | \n",
"
\n",
" \n",
" | 553 | \n",
" Guglielmo Vicario | \n",
" Empoli | \n",
"
\n",
" \n",
" | 554 | \n",
" Jeroen Zoet | \n",
" Spezia | \n",
"
\n",
" \n",
" | 555 | \n",
" Petar Zovko | \n",
" Spezia | \n",
"
\n",
" \n",
"
\n",
"
556 rows × 2 columns
\n",
"
"
],
"text/plain": [
" player team\n",
"0 Tammy Abraham Roma\n",
"1 Francesco Acerbi Inter\n",
"2 Yacine Adli Milan\n",
"3 Michel Aebischer Bologna\n",
"4 Felix Afena-Gyan Cremonese\n",
".. ... ...\n",
"551 Ciprian Tătărușanu Milan\n",
"552 Pietro Terracciano Fiorentina\n",
"553 Guglielmo Vicario Empoli\n",
"554 Jeroen Zoet Spezia\n",
"555 Petar Zovko Spezia\n",
"\n",
"[556 rows x 2 columns]"
]
},
"execution_count": 102,
"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": 103,
"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": 104,
"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": 105,
"id": "ffd6091c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" player surname\n",
"0 Tammy Abraham Abraham\n",
"1 Francesco Acerbi Acerbi\n",
"2 Yacine Adli Adli\n",
"3 Michel Aebischer Aebischer\n",
"4 Felix Afena-Gyan Afena-Gyan\n",
"5 Kevin Agudelo Agudelo\n",
"6 Ola Aina Aina\n",
"7 Emanuel Aiwum Aiwum\n",
"8 Jean-Daniel Akpa-Akpro Akpa-Akpro\n",
"9 Luis Alberto Alberto\n",
"10 Agustín Álvarez Martínez Martinez\n",
"11 Kelvin Amian Amian\n",
"12 Bruno Amione Amione\n",
"13 Bruno Amione Amione\n",
"14 Ethan Ampadu Ampadu\n",
"15 Sofyan Amrabat Amrabat\n",
"16 Felipe Anderson Anderson\n",
"17 Janis Antiste Antiste\n",
"18 Marcos Antônio Antonio\n",
"19 Valentin Antov Antov\n",
"20 Marko Arnautović Arnautovic\n",
"21 Tolgay Arslan Arslan\n",
"22 Arthur Arthur\n",
"23 Santiago Ascacíbar Ascacibar\n",
"24 Kristoffer Askildsen Askildsen\n",
"25 Kristjan Asllani Asllani\n",
"26 Emil Audero Audero\n",
"27 Tommaso Augello Augello\n",
"28 Kaan Ayhan Ayhan\n",
"29 Jaime Báez Baez\n",
"30 Nedim Bajrami Bajrami\n",
"31 Tommaso Baldanzi Baldanzi\n",
"32 Fodé Ballo-Touré Ballo-Toure\n",
"33 Lameck Banda Banda\n",
"34 Filippo Bandinelli Bandinelli\n",
"35 Antonín Barák Barak\n",
"36 Antonín Barák Barak\n",
"37 Andrea Barberis Barberis\n",
"38 Nicolò Barella Barella\n",
"39 Musa Barrow Barrow\n",
"40 Federico Baschirotto Baschirotto\n",
"41 Toma Bašić Basic\n",
"42 Alessandro Bastoni Bastoni\n",
"43 Simone Bastoni Bastoni\n",
"44 Brian Bayeye Bayeye\n",
"45 Rodrigo Becão Becao\n",
"46 Julius Beck Beck\n",
"47 Raoul Bellanova Bellanova\n",
"48 Andrea Belotti Belotti\n",
"49 Marco Benassi Benassi\n",
"50 Marco Benassi Benassi\n",
"51 Ismaël Bennacer Bennacer\n",
"52 Domenico Berardi Berardi\n",
"53 Bartosz Bereszyński Bereszynski\n",
"54 Beto Beto\n",
"55 Matteo Bianchetti Bianchetti\n",
"56 Alessandro Bianco Bianco\n",
"57 Jaka Bijol Bijol\n",
"58 Cristiano Biraghi Biraghi\n",
"59 Samuele Birindelli Birindelli\n",
"60 Kristijan Bistrović Bistrovic\n",
"61 Alexis Blin Blin\n",
"62 Jeremie Boga Boga\n",
"63 Emil Bohinen Bohinen\n",
"64 Giacomo Bonaventura Bonaventura\n",
"65 Federico Bonazzoli Bonazzoli\n",
"66 Warren Bondo Bondo\n",
"67 Kevin Bonifazi Bonifazi\n",
"68 Leonardo Bonucci Bonucci\n",
"69 Erik Botheim Botheim\n",
"70 Mehdi Bourabia Bourabia\n",
"71 Edoardo Bove Bove\n",
"72 Jayden Braaf Braaf\n",
"73 Domagoj Bradarić Bradaric\n",
"74 Gleison Bremer Bremer\n",
"75 Dylan Bronn Bronn\n",
"76 Marcelo Brozović Brozovic\n",
"77 Cristian Buonaiuto Buonaiuto\n",
"78 Alessandro Buongiorno Buongiorno\n",
"79 Juan Cabal Cabal\n",
"80 Liberato Cacace Cacace\n",
"81 Davide Calabria Calabria\n",
"82 Mattia Caldara Caldara\n",
"83 Luca Caldirola Caldirola\n",
"84 Hakan Çalhanoğlu Calhanoglu\n",
"85 Mohamed Camara Camara\n",
"86 Nicolò Cambiaghi Cambiaghi\n",
"87 Andrea Cambiaso Cambiaso\n",
"88 Matteo Cancellieri Cancellieri\n",
"89 Antonio Candreva Candreva\n",
"90 Gianluca Caprari Caprari\n",
"91 Francesco Caputo Caputo\n",
"92 Francesco Caputo Caputo\n",
"93 Andrea Carboni Carboni\n",
"94 Valentin Carboni Carboni\n",
"95 Carlos Carlos\n",
"96 Marco Carnesecchi Carnesecchi\n",
"97 Nicolò Casale Casale\n",
"98 Michele Castagnetti Castagnetti\n",
"99 Gaetano Castrovilli Castrovilli\n",
"100 Danilo Cataldi Cataldi\n",
"101 Federico Ceccherini Ceccherini\n",
"102 Assan Ceesay Ceesay\n",
"103 Emil Ceide Ceide\n",
"104 Zeki Çelik Celik\n",
"105 Federico Chiesa Chiesa\n",
"106 Vlad Chiricheș Chiriches\n",
"107 Daniel Ciofani Ciofani\n",
"108 Tio Cipot Cipot\n",
"109 Patrick Ciurria Ciurria\n",
"110 Omar Colley Colley\n",
"111 Lorenzo Colombo Colombo\n",
"112 Andrea Colpani Colpani\n",
"113 Andrea Consigli Consigli\n",
"114 Andrea Conti Conti\n",
"115 Diego Coppola Coppola\n",
"116 Joaquín Correa Correa\n",
"117 Alessandro Cortinovis Cortinovis\n",
"118 Lassana Coulibaly Coulibaly\n",
"119 Bryan Cristante Cristante\n",
"120 Domen Črnigoj Crnigoj\n",
"121 Juan Cuadrado Cuadrado\n",
"122 Marco D'Alessandro DAlessandro\n",
"123 Danilo D'Ambrosio DAmbrosio\n",
"124 Luca D'Andrea DAndrea\n",
"125 Flavius Daniliuc Daniliuc\n",
"126 Danilo Danilo\n",
"127 Matteo Darmian Darmian\n",
"128 Paweł Dawidowicz Dawidowicz\n",
"129 Charles De Ketelaere Ketelaere\n",
"130 Manuel De Luca Luca\n",
"131 Mattia De Sciglio Sciglio\n",
"132 Lorenzo De Silvestri Silvestri\n",
"133 Koni De Winter Winter\n",
"134 Grégoire Defrel Defrel\n",
"135 Duccio Degli Innocenti Innocenti\n",
"136 Merih Demiral Demiral\n",
"137 Diego Demme Demme\n",
"138 Fabio Depaoli Depaoli\n",
"139 Fabio Depaoli Depaoli\n",
"140 Kastriot Dermaku Dermaku\n",
"141 Cyriel Dessers Dessers\n",
"142 Sergiño Dest Dest\n",
"143 Mattia Destro Destro\n",
"144 Gerard Deulofeu Deulofeu\n",
"145 Samuel Di Carmine Carmine\n",
"146 Federico Di Francesco Francesco\n",
"147 Michele Di Gregorio Gregorio\n",
"148 Giovanni Di Lorenzo Lorenzo\n",
"149 Ángel Di María Maria\n",
"150 Boulaye Dia Dia\n",
"151 Brahim Díaz Diaz\n",
"152 Federico Dimarco Dimarco\n",
"153 Koffi Djidji Djidji\n",
"154 Berat Djimsiti Djimsiti\n",
"155 Dodô Dodo\n",
"156 Josh Doig Doig\n",
"157 Nicolás Domínguez Dominguez\n",
"158 Giulio Donati Donati\n",
"159 Bartłomiej Drągowski Dragowski\n",
"160 Ondrej Duda Duda\n",
"161 Denzel Dumfries Dumfries\n",
"162 Alfred Duncan Duncan\n",
"163 Paulo Dybala Dybala\n",
"164 Edin Džeko Dzeko\n",
"165 Festy Ebosele Ebosele\n",
"166 Enzo Ebosse Ebosse\n",
"167 Tyronne Ebuehi Ebuehi\n",
"168 Éderson Ederson\n",
"169 Kingsley Ehizibue Ehizibue\n",
"170 Albin Ekdal Ekdal\n",
"171 Emmanuel Ekong Ekong\n",
"172 Mikael Ellertsson Ellertsson\n",
"173 Elif Elmas Elmas\n",
"174 Martin Erlic Erlic\n",
"175 Gonzalo Escalante Escalante\n",
"176 Salvatore Esposito Esposito\n",
"177 Nicolò Fagioli Fagioli\n",
"178 Wladimiro Falcone Falcone\n",
"179 Davide Faraoni Faraoni\n",
"180 Federico Fazio Fazio\n",
"181 Jacopo Fazzini Fazzini\n",
"182 Lewis Ferguson Ferguson\n",
"183 Alex Ferrari Ferrari\n",
"184 Alex Ferrari Ferrari\n",
"185 Salvador Ferrer Ferrer\n",
"186 Alessandro Florenzi Florenzi\n",
"187 Davide Frattesi Frattesi\n",
"188 Matteo Gabbia Gabbia\n",
"189 Manolo Gabbiadini Gabbiadini\n",
"190 Gianluca Gaetano Gaetano\n",
"191 Roberto Gagliardini Gagliardini\n",
"192 Antonino Gallo Gallo\n",
"193 Federico Gatti Gatti\n",
"194 Valentin Gendrey Gendrey\n",
"195 Paolo Ghiglione Ghiglione\n",
"196 Mario Gila Gila\n",
"197 Olivier Giroud Giroud\n",
"198 Pierluigi Gollini Gollini\n",
"199 Joan Gonzàlez Gonzalez\n",
"200 Nicolás González Gonzalez\n",
"201 Robin Gosens Gosens\n",
"202 Alberto Grassi Grassi\n",
"203 Koray Günter Gunter\n",
"204 Emmanuel Gyasi Gyasi\n",
"205 Norbert Gyömbér Gyomber\n",
"206 Christian Gytkjær Gytkjr\n",
"207 Nicolas Haas Haas\n",
"208 Samir Handanović Handanovic\n",
"209 Abdou Harroui Harroui\n",
"210 Hans Hateboer Hateboer\n",
"211 Liam Henderson Henderson\n",
"212 Jack Hendry Hendry\n",
"213 Matheus Henrique Henrique\n",
"214 Thomas Henry Henry\n",
"215 Theo Hernández Hernandez\n",
"216 Isak Hien Hien\n",
"217 Morten Hjulmand Hjulmand\n",
"218 Emil Holm Holm\n",
"219 Martin Hongla Hongla\n",
"220 Petko Hristov Hristov\n",
"221 Ajdin Hrustic Hrustic\n",
"222 Elseid Hysaj Hysaj\n",
"223 Rasmus Højlund Hjlund\n",
"224 Roger Ibanez Ibanez\n",
"225 Igor Igor\n",
"226 Jonathan Ikone Ikone\n",
"227 Ivan Ilić Ilic\n",
"228 Samuel Iling-Junior Iling-Junior\n",
"229 Emirhan İlkhan Ilkhan\n",
"230 Ciro Immobile Immobile\n",
"231 Ardian Ismajli Ismajli\n",
"232 Armando Izzo Izzo\n",
"233 Mato Jajalo Jajalo\n",
"234 Juan Jesus Jesus\n",
"235 Þórir Jóhann Helgason Helgason\n",
"236 Luka Jović Jovic\n",
"237 Hamed Junior Traorè Traore\n",
"238 Yayah Kallon Kallon\n",
"239 Pierre Kalulu Kalulu\n",
"240 Yann Karamoh Karamoh\n",
"241 Rick Karsdorp Karsdorp\n",
"242 Denso Kasius Kasius\n",
"243 Grigoris Kastanos Kastanos\n",
"244 Moise Kean Kean\n",
"245 Jakub Kiwior Kiwior\n",
"246 Simon Kjær Kjr\n",
"247 Teun Koopmeiners Koopmeiners\n",
"248 Filip Kostić Kostic\n",
"249 Christian Kouamé Kouame\n",
"250 Viktor Kovalenko Kovalenko\n",
"251 Julian Kristoffersen Kristoffersen\n",
"252 Rade Krunić Krunic\n",
"253 Marash Kumbulla Kumbulla\n",
"254 Khvicha Kvaratskhelia Kvaratskhelia\n",
"255 Giorgos Kyriakopoulos Kyriakopoulos\n",
"256 Sam Lammers Lammers\n",
"257 Sam Lammers Lammers\n",
"258 Kevin Lasagna Lasagna\n",
"259 Armand Lauriente Lauriente\n",
"260 Valentino Lazaro Lazaro\n",
"261 Marko Lazetić Lazetic\n",
"262 Darko Lazović Lazovic\n",
"263 Manuel Lazzari Lazzari\n",
"264 Rafael Leão Leao\n",
"265 Mehdi Léris Leris\n",
"266 Karol Linetty Linetty\n",
"267 Marcin Listkowski Listkowski\n",
"268 Stanislav Lobotka Lobotka\n",
"269 Manuel Locatelli Locatelli\n",
"270 Luka Lochoshvili Lochoshvili\n",
"271 Ademola Lookman Lookman\n",
"272 Maxime Lopez Lopez\n",
"273 Matteo Lovato Lovato\n",
"274 Sandi Lovrić Lovric\n",
"275 Hirving Lozano Lozano\n",
"276 Jhon Lucumí Lucumi\n",
"277 José Luis Palomino Palomino\n",
"278 Romelu Lukaku Lukaku\n",
"279 Saša Lukić Lukic\n",
"280 Sebastiano Luperto Luperto\n",
"281 Charalambos Lykogiannis Lykogiannis\n",
"282 Giulio Maggiore Maggiore\n",
"283 Giangiacomo Magnani Magnani\n",
"284 Mike Maignan Maignan\n",
"285 Jean-Victor Makengo Makengo\n",
"286 Lorenzo Malagrida Malagrida\n",
"287 Daniel Maldini Maldini\n",
"288 Youssef Maleh Maleh\n",
"289 Youssef Maleh Maleh\n",
"290 Ruslan Malinovskyi Malinovskyi\n",
"291 Gianluca Mancini Mancini\n",
"292 Rolando Mandragora Mandragora\n",
"293 Riccardo Marchizza Marchizza\n",
"294 Gian Marco Ferrari Ferrari\n",
"295 Pablo Marí Mari\n",
"296 Răzvan Marin Marin\n",
"297 Marlon Marlon\n",
"298 Luca Marrone Marrone\n",
"299 Lautaro Martínez Martinez\n",
"300 Lucas Martínez Quarta Quarta\n",
"301 Adam Marušić Marusic\n",
"302 Adam Masina Masina\n",
"303 Nemanja Matić Matic\n",
"304 Luís Maximiano Maximiano\n",
"305 Pasquale Mazzocchi Mazzocchi\n",
"306 Weston McKennie McKennie\n",
"307 Gary Medel Medel\n",
"308 Soualiho Meïté Meite\n",
"309 Alex Meret Meret\n",
"310 Yıldırım Mert Çetin Cetin\n",
"311 Junior Messias Messias\n",
"312 Tommaso Milanese Milanese\n",
"313 Nikola Milenković Milenkovic\n",
"314 Arkadiusz Milik Milik\n",
"315 Sergej Milinković-Savić Milinkovic-Savic\n",
"316 Vanja Milinković-Savić Milinkovic-Savic\n",
"317 Kim Min-jae Min-jae\n",
"318 Aleksei Miranchuk Miranchuk\n",
"319 Fabio Miretti Miretti\n",
"320 Henrikh Mkhitaryan Mkhitaryan\n",
"321 Salvatore Molina Molina\n",
"322 Daniele Montevago Montevago\n",
"323 Lorenzo Montipò Montipo\n",
"324 Nikola Moro Moro\n",
"325 Dany Mota Mota\n",
"326 João Moutinho Moutinho\n",
"327 Mert Müldür Muldur\n",
"328 Luis Muriel Muriel\n",
"329 Jeison Murillo Murillo\n",
"330 Nicola Murru Murru\n",
"331 Juan Musso Musso\n",
"332 Joakim Mæhle Mhle\n",
"333 Michel Ndary Adopo Adopo\n",
"334 Tanguy Ndombele Ndombele\n",
"335 Ilija Nestorovski Nestorovski\n",
"336 Cyril Ngonge Ngonge\n",
"337 Hans Nicolussi Caviglia Caviglia\n",
"338 Dimitris Nikolaou Nikolaou\n",
"339 Bram Nuytinck Nuytinck\n",
"340 Bram Nuytinck Nuytinck\n",
"341 M'Bala Nzola Nzola\n",
"342 Pedro Obiang Obiang\n",
"343 Guillermo Ochoa Ochoa\n",
"344 David Okereke Okereke\n",
"345 Caleb Okoli Okoli\n",
"346 Mathías Olivera Olivera\n",
"347 André Onana Onana\n",
"348 Divock Origi Origi\n",
"349 Riccardo Orsolini Orsolini\n",
"350 Victor Osimhen Osimhen\n",
"351 Remi Oudin Oudin\n",
"352 Adam Ounas Ounas\n",
"353 Flavio Paoletti Paoletti\n",
"354 Leandro Paredes Paredes\n",
"355 Fabiano Parisi Parisi\n",
"356 Mario Pašalić Pasalic\n",
"357 Patric Patric\n",
"358 Rui Patrício Patricio\n",
"359 Pedro Pedro\n",
"360 Gianluca Pegolo Pegolo\n",
"361 Pietro Pellegri Pellegri\n",
"362 Lorenzo Pellegrini Pellegrini\n",
"363 Pepín Pepin\n",
"364 Roberto Pereyra Pereyra\n",
"365 Nehuén Pérez Perez\n",
"366 Mattia Perin Perin\n",
"367 Matteo Pessina Pessina\n",
"368 Andrea Petagna Petagna\n",
"369 Giuseppe Pezzella Pezzella\n",
"370 Krzysztof Piątek Piatek\n",
"371 Roberto Piccoli Piccoli\n",
"372 Charles Pickel Pickel\n",
"373 Andrea Pinamonti Pinamonti\n",
"374 Lorenzo Pirola Pirola\n",
"375 Marko Pjaca Pjaca\n",
"376 Tommaso Pobega Pobega\n",
"377 Matteo Politano Politano\n",
"378 Marin Pongračić Pongracic\n",
"379 Stefan Posch Posch\n",
"380 Ivan Provedel Provedel\n",
"381 Ignacio Pussetto Pussetto\n",
"382 Niklas Pyyhtiä Pyyhtia\n",
"383 Fabio Quagliarella Quagliarella\n",
"384 Giacomo Quagliata Quagliata\n",
"385 Adrien Rabiot Rabiot\n",
"386 Nemanja Radonjić Radonjic\n",
"387 Ivan Radovanović Radovanovic\n",
"388 Ionuț Radu Radu\n",
"389 Luca Ranieri Ranieri\n",
"390 Andrea Ranocchia Ranocchia\n",
"391 Filippo Ranocchia Ranocchia\n",
"392 Giacomo Raspadori Raspadori\n",
"393 Giacomo Raspadori Raspadori\n",
"394 Ante Rebić Rebic\n",
"395 Arkadiusz Reca Reca\n",
"396 Panagiotis Retsos Retsos\n",
"397 Franck Ribéry Ribery\n",
"398 Samuele Ricci Ricci\n",
"399 Tomás Rincón Rincon\n",
"400 Pablo Rodríguez Rodriguez\n",
"401 Ricardo Rodríguez Rodriguez\n",
"402 Rogério Rogerio\n",
"403 Alessio Romagnoli Romagnoli\n",
"404 Luka Romero Romero\n",
"405 Marten de Roon Roon\n",
"406 Nicolò Rovella Rovella\n",
"407 Nicolò Rovella Rovella\n",
"408 Amir Rrahmani Rrahmani\n",
"409 Ruan Ruan\n",
"410 Daniele Rugani Rugani\n",
"411 Matteo Ruggeri Ruggeri\n",
"412 Mário Rui Rui\n",
"413 Abdelhamid Sabiri Sabiri\n",
"414 Alexis Saelemaekers Saelemaekers\n",
"415 Jacopo Sala Sala\n",
"416 Lazar Samardzic Samardzic\n",
"417 Junior Sambia Sambia\n",
"418 Antonio Sanabria Sanabria\n",
"419 Leandro Sanca Sanca\n",
"420 Alex Sandro Sandro\n",
"421 Nicola Sansone Sansone\n",
"422 Riccardo Saponara Saponara\n",
"423 Martin Satriano Satriano\n",
"424 Giorgio Scalvini Scalvini\n",
"425 Jerdy Schouten Schouten\n",
"426 Perr Schuurs Schuurs\n",
"427 Demba Seck Seck\n",
"428 Jacopo Segre Segre\n",
"429 Vivaldo Semedo Semedo\n",
"430 Stefano Sensi Sensi\n",
"431 Luigi Sepe Sepe\n",
"432 Leonardo Sernicola Sernicola\n",
"433 Stephan El Shaarawy Shaarawy\n",
"434 Eldor Shomurodov Shomurodov\n",
"435 Marco Silvestri Silvestri\n",
"436 Giovanni Simeone Simeone\n",
"437 Wilfried Singo Singo\n",
"438 Leo Skiri Østigård stigard\n",
"439 Łukasz Skorupski Skorupski\n",
"440 Milan Škriniar Skriniar\n",
"441 Chris Smalling Smalling\n",
"442 Ola Solbakken Solbakken\n",
"443 Brandon Soppy Soppy\n",
"444 Brandon Soppy Soppy\n",
"445 Roberto Soriano Soriano\n",
"446 Joaquin Sosa Sosa\n",
"447 Riccardo Sottil Sottil\n",
"448 Matìas Soulé Soule\n",
"449 Adama Soumaoro Soumaoro\n",
"450 Leonardo Spinazzola Spinazzola\n",
"451 Marco Sportiello Sportiello\n",
"452 Petar Stojanović Stojanovic\n",
"453 Gabriel Strefezza Strefezza\n",
"454 Dávid Strelec Strelec\n",
"455 Isaac Success Success\n",
"456 Ibrahim Sulemana Sulemana\n",
"457 Wojciech Szczęsny Szczesny\n",
"458 Benjamin Tahirovic Tahirovic\n",
"459 Adrien Tameze Tameze\n",
"460 Ciprian Tătărușanu Tatarusanu\n",
"461 Filippo Terracciano Terracciano\n",
"462 Pietro Terracciano Terracciano\n",
"463 Aleksa Terzić Terzic\n",
"464 Malick Thiaw Thiaw\n",
"465 Kristian Thorstvedt Thorstvedt\n",
"466 Jeremy Toljan Toljan\n",
"467 Rafael Tolói Toloi\n",
"468 Fikayo Tomori Tomori\n",
"469 Sandro Tonali Tonali\n",
"470 William Troost-Ekong Troost-Ekong\n",
"471 Frank Tsadjout Tsadjout\n",
"472 Alessandro Tuia Tuia\n",
"473 Iyenoma Udogie Udogie\n",
"474 Samuel Umtiti Umtiti\n",
"475 Diego Valencia Valencia\n",
"476 Emanuele Valeri Valeri\n",
"477 Mattia Valoti Valoti\n",
"478 Johan Vásquez Vasquez\n",
"479 Matías Vecino Vecino\n",
"480 Miguel Veloso Veloso\n",
"481 Lorenzo Venuti Venuti\n",
"482 Daniele Verde Verde\n",
"483 Simone Verdi Verdi\n",
"484 Valerio Verre Verre\n",
"485 Guglielmo Vicario Vicario\n",
"486 Ronaldo Vieira Vieira\n",
"487 Emanuel Vignato Vignato\n",
"488 Samuele Vignato Vignato\n",
"489 Tonny Vilhena Vilhena\n",
"490 Gonzalo Villar Villar\n",
"491 Matías Viña Vina\n",
"492 Dušan Vlahović Vlahovic\n",
"493 Nikola Vlašić Vlasic\n",
"494 Joel Voelkerling Persson Persson\n",
"495 Mërgim Vojvoda Vojvoda\n",
"496 Cristian Volpato Volpato\n",
"497 Aster Vranckx Vranckx\n",
"498 Stefan de Vrij Vrij\n",
"499 Walace Walace\n",
"500 Sebastian Walukiewicz Walukiewicz\n",
"501 Georginio Wijnaldum Wijnaldum\n",
"502 Harry Winks Winks\n",
"503 Gerard Yepes Yepes\n",
"504 Mattia Zaccagni Zaccagni\n",
"505 Denis Zakaria Zakaria\n",
"506 Nicola Zalewski Zalewski\n",
"507 Andre-Frank Zambo Anguissa Anguissa\n",
"508 Luca Zanimacchia Zanimacchia\n",
"509 Nicolò Zaniolo Zaniolo\n",
"510 Alessandro Zanoli Zanoli\n",
"511 Alessandro Zanoli Zanoli\n",
"512 Duván Zapata Zapata\n",
"513 Davide Zappacosta Zappacosta\n",
"514 Alessio Zerbin Zerbin\n",
"515 Piotr Zieliński Zielinski\n",
"516 David Zima Zima\n",
"517 Joshua Zirkzee Zirkzee\n",
"518 Jeroen Zoet Zoet\n",
"519 Nadir Zortea Zortea\n",
"520 Petar Zovko Zovko\n",
"521 Szymon Żurkowski Zurkowski\n",
"522 Szymon Żurkowski Zurkowski\n",
"523 Milan Đurić uric\n",
"524 Filip Đuričić uricic\n",
"525 Emil Audero Audero\n",
"526 Marco Carnesecchi Carnesecchi\n",
"527 Andrea Consigli Consigli\n",
"528 Michele Di Gregorio Gregorio\n",
"529 Bartłomiej Drągowski Dragowski\n",
"530 Wladimiro Falcone Falcone\n",
"531 Pierluigi Gollini Gollini\n",
"532 Samir Handanović Handanovic\n",
"533 Mike Maignan Maignan\n",
"534 Luís Maximiano Maximiano\n",
"535 Alex Meret Meret\n",
"536 Vanja Milinković-Savić Milinkovic-Savic\n",
"537 Lorenzo Montipò Montipo\n",
"538 Juan Musso Musso\n",
"539 Guillermo Ochoa Ochoa\n",
"540 André Onana Onana\n",
"541 Rui Patrício Patricio\n",
"542 Gianluca Pegolo Pegolo\n",
"543 Mattia Perin Perin\n",
"544 Ivan Provedel Provedel\n",
"545 Ionuț Radu Radu\n",
"546 Luigi Sepe Sepe\n",
"547 Marco Silvestri Silvestri\n",
"548 Łukasz Skorupski Skorupski\n",
"549 Marco Sportiello Sportiello\n",
"550 Wojciech Szczęsny Szczesny\n",
"551 Ciprian Tătărușanu Tatarusanu\n",
"552 Pietro Terracciano Terracciano\n",
"553 Guglielmo Vicario Vicario\n",
"554 Jeroen Zoet Zoet\n",
"555 Petar Zovko Zovko\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": 106,
"id": "3e759b1b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ostigard\n",
"Kim\n",
"Hojlund\n",
"Gytkjaer\n",
"Augusto\n",
"Maehle\n",
"Kjaer\n",
"Djuricic\n",
"Djuric\n",
"Cabral\n",
"Alvarez\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" FROM | \n",
" TO | \n",
" TEAM | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" stigard | \n",
" Ostigard | \n",
" Napoli | \n",
"
\n",
" \n",
" | 1 | \n",
" Min-jae | \n",
" Kim | \n",
" Napoli | \n",
"
\n",
" \n",
" | 2 | \n",
" Hjlund | \n",
" Hojlund | \n",
" Atalanta | \n",
"
\n",
" \n",
" | 3 | \n",
" Gytkjr | \n",
" Gytkjaer | \n",
" Monza | \n",
"
\n",
" \n",
" | 4 | \n",
" Carlos | \n",
" Augusto | \n",
" Monza | \n",
"
\n",
" \n",
" | 5 | \n",
" Mhle | \n",
" Maehle | \n",
" Atalanta | \n",
"
\n",
" \n",
" | 6 | \n",
" Kjr | \n",
" Kjaer | \n",
" Milan | \n",
"
\n",
" \n",
" | 7 | \n",
" uricic | \n",
" Djuricic | \n",
" Sampdoria | \n",
"
\n",
" \n",
" | 8 | \n",
" uric | \n",
" Djuric | \n",
" Hellas Verona | \n",
"
\n",
" \n",
" | 9 | \n",
" Arthur | \n",
" Cabral | \n",
" Fiorentina | \n",
"
\n",
" \n",
" | 10 | \n",
" Martinez | \n",
" Alvarez | \n",
" Sassuolo | \n",
"
\n",
" \n",
"
\n",
"
"
],
"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 Monza\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"
]
},
"execution_count": 106,
"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": 107,
"id": "f96eaaa1",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2263921821.py:17: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['surname'][i] = spl[-1]\n",
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2263921821.py:18: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['initial'][i] = ''\n",
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2263921821.py:14: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['surname'][i] = spl[-2]\n",
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2263921821.py:15: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['initial'][i] = spl[-1][0]\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" id | \n",
" r | \n",
" name | \n",
" team | \n",
" surname | \n",
" initial | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 572 | \n",
" P | \n",
" Meret | \n",
" Napoli | \n",
" Meret | \n",
" | \n",
"
\n",
" \n",
" | 1 | \n",
" 2814 | \n",
" P | \n",
" Provedel | \n",
" Lazio | \n",
" Provedel | \n",
" | \n",
"
\n",
" \n",
" | 2 | \n",
" 4964 | \n",
" P | \n",
" Vicario | \n",
" Empoli | \n",
" Vicario | \n",
" | \n",
"
\n",
" \n",
" | 3 | \n",
" 453 | \n",
" P | \n",
" Szczesny | \n",
" Juventus | \n",
" Szczesny | \n",
" | \n",
"
\n",
" \n",
" | 4 | \n",
" 2134 | \n",
" P | \n",
" Falcone | \n",
" Lecce | \n",
" Falcone | \n",
" | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 538 | \n",
" 5512 | \n",
" A | \n",
" De Luca | \n",
" Sampdoria | \n",
" Luca | \n",
" | \n",
"
\n",
" \n",
" | 539 | \n",
" 5837 | \n",
" A | \n",
" Voelkerling Persson | \n",
" Lecce | \n",
" Persson | \n",
" | \n",
"
\n",
" \n",
" | 540 | \n",
" 6113 | \n",
" A | \n",
" Montevago | \n",
" Sampdoria | \n",
" Montevago | \n",
" | \n",
"
\n",
" \n",
" | 541 | \n",
" 6143 | \n",
" A | \n",
" Krollis | \n",
" Spezia | \n",
" Krollis | \n",
" | \n",
"
\n",
" \n",
" | 542 | \n",
" 6160 | \n",
" A | \n",
" Vivaldo | \n",
" Udinese | \n",
" Vivaldo | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
543 rows × 6 columns
\n",
"
"
],
"text/plain": [
" id r name team surname initial\n",
"0 572 P Meret Napoli Meret \n",
"1 2814 P Provedel Lazio Provedel \n",
"2 4964 P Vicario Empoli Vicario \n",
"3 453 P Szczesny Juventus Szczesny \n",
"4 2134 P Falcone Lecce Falcone \n",
".. ... .. ... ... ... ...\n",
"538 5512 A De Luca Sampdoria Luca \n",
"539 5837 A Voelkerling Persson Lecce Persson \n",
"540 6113 A Montevago Sampdoria Montevago \n",
"541 6143 A Krollis Spezia Krollis \n",
"542 6160 A Vivaldo Udinese Vivaldo \n",
"\n",
"[543 rows x 6 columns]"
]
},
"execution_count": 107,
"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['surname'][i] = spl[-2]\n",
" fc_players['initial'][i] = spl[-1][0]\n",
" else:\n",
" fc_players['surname'][i] = spl[-1]\n",
" fc_players['initial'][i] = ''\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": 108,
"id": "9c50e4b5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2200947104.py:4: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['fb_ID'][i] = -1\n",
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2200947104.py:11: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['fb_ID'][i] = j\n"
]
}
],
"source": [
"fc_players['fb_ID'] = fc_players['id']\n",
"\n",
"for i in range(fc_players.shape[0]):\n",
" fc_players['fb_ID'][i] = -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['fb_ID'][i] = 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": 109,
"id": "18f6c5f2",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\362391242.py:10: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players['fb_ID'][i] = j\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Gollini from previous team stats\n",
"Mirante not found\n",
"Sarr M. not found\n",
"Lamanna not found\n",
"Ujkani not found\n",
"Berisha not found\n",
"Marchetti not found\n",
"Perilli not found\n",
"Padelli not found\n",
"Perisan not found\n",
"Bardi not found\n",
"Cordaz not found\n",
"Pinsoglio not found\n",
"Fiorillo not found\n",
"Cragno not found\n",
"Sirigu not found\n",
"Cerofolini not found\n",
"Rossi F. not found\n",
"Ravaglia F. not found\n",
"Brancolini not found\n",
"Bleve not found\n",
"Berardi A. not found\n",
"Russo A. not found\n",
"Gemello not found\n",
"Ravaglia not found\n",
"Boer not found\n",
"Adamonis not found\n",
"Marfella not found\n",
"Piana not found\n",
"Bagnolini not found\n",
"Svilar not found\n",
"Sorrentino A. not found\n",
"Ciezkowski not found\n",
"Saro not found\n",
"Vasquez D. not found\n",
"Turk not found\n",
"Kyriakopoulos from previous team stats\n",
"Llorente D. not found\n",
"Pellegrini Lu. not found\n",
"Gravillon not found\n",
"Gunter from previous team stats\n",
"Ceccaroni not found\n",
"Bereszynski from previous team stats\n",
"Zortea from previous team stats\n",
"Aiwu not found\n",
"Zeefuik not found\n",
"Romagnoli S. not found\n",
"Wisniewski not found\n",
"Tonelli not found\n",
"Radu from previous team stats\n",
"Paletta not found\n",
"Fares not found\n",
"Romagna not found\n",
"Cassandro not found\n",
"Amey not found\n",
"Zanotti not found\n",
"Buta not found\n",
"Abankwah not found\n",
"Guessand A. not found\n",
"Guarino not found\n",
"Pogba not found\n",
"Bajrami from previous team stats\n",
"Ilic from previous team stats\n",
"Machin not found\n",
"Cuisance not found\n",
"Akpa Akpro not found\n",
"Vieira from previous team stats\n",
"Galdames not found\n",
"Abildgaard not found\n",
"Vignato from previous team stats\n",
"Bakayoko not found\n",
"Darboe not found\n",
"Urbanski not found\n",
"Bertini not found\n",
"Trimboli not found\n",
"Pafundi not found\n",
"Samek not found\n",
"Ilkhan from previous team stats\n",
"Acella not found\n",
"Faticanti not found\n",
"Thauvin not found\n",
"Brekalo not found\n",
"Gaich not found\n",
"Piccoli from previous team stats\n",
"Shomurodov from previous team stats\n",
"Ibrahimovic not found\n",
"Oddei not found\n",
"Raimondo not found\n",
"Kaio Jorge not found\n",
"Krollis not found\n",
"Vivaldo not found\n"
]
}
],
"source": [
"exceptions = ['pellegrini', 'berardi', 'romagnoli'] # 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['fb_ID'][i] = 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": 110,
"id": "3b4a36af",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" id | \n",
" r | \n",
" name | \n",
" team | \n",
" surname | \n",
" initial | \n",
" fb_ID | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 572 | \n",
" P | \n",
" Meret | \n",
" Napoli | \n",
" Meret | \n",
" | \n",
" 535 | \n",
"
\n",
" \n",
" | 1 | \n",
" 2814 | \n",
" P | \n",
" Provedel | \n",
" Lazio | \n",
" Provedel | \n",
" | \n",
" 544 | \n",
"
\n",
" \n",
" | 2 | \n",
" 4964 | \n",
" P | \n",
" Vicario | \n",
" Empoli | \n",
" Vicario | \n",
" | \n",
" 553 | \n",
"
\n",
" \n",
" | 3 | \n",
" 453 | \n",
" P | \n",
" Szczesny | \n",
" Juventus | \n",
" Szczesny | \n",
" | \n",
" 550 | \n",
"
\n",
" \n",
" | 4 | \n",
" 2134 | \n",
" P | \n",
" Falcone | \n",
" Lecce | \n",
" Falcone | \n",
" | \n",
" 530 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 538 | \n",
" 5512 | \n",
" A | \n",
" De Luca | \n",
" Sampdoria | \n",
" Luca | \n",
" | \n",
" 130 | \n",
"
\n",
" \n",
" | 539 | \n",
" 5837 | \n",
" A | \n",
" Voelkerling Persson | \n",
" Lecce | \n",
" Persson | \n",
" | \n",
" 494 | \n",
"
\n",
" \n",
" | 540 | \n",
" 6113 | \n",
" A | \n",
" Montevago | \n",
" Sampdoria | \n",
" Montevago | \n",
" | \n",
" 322 | \n",
"
\n",
" \n",
" | 541 | \n",
" 6143 | \n",
" A | \n",
" Krollis | \n",
" Spezia | \n",
" Krollis | \n",
" | \n",
" -1 | \n",
"
\n",
" \n",
" | 542 | \n",
" 6160 | \n",
" A | \n",
" Vivaldo | \n",
" Udinese | \n",
" Vivaldo | \n",
" | \n",
" -1 | \n",
"
\n",
" \n",
"
\n",
"
543 rows × 7 columns
\n",
"
"
],
"text/plain": [
" id r name team surname initial fb_ID\n",
"0 572 P Meret Napoli Meret 535\n",
"1 2814 P Provedel Lazio Provedel 544\n",
"2 4964 P Vicario Empoli Vicario 553\n",
"3 453 P Szczesny Juventus Szczesny 550\n",
"4 2134 P Falcone Lecce Falcone 530\n",
".. ... .. ... ... ... ... ...\n",
"538 5512 A De Luca Sampdoria Luca 130\n",
"539 5837 A Voelkerling Persson Lecce Persson 494\n",
"540 6113 A Montevago Sampdoria Montevago 322\n",
"541 6143 A Krollis Spezia Krollis -1\n",
"542 6160 A Vivaldo Udinese Vivaldo -1\n",
"\n",
"[543 rows x 7 columns]"
]
},
"execution_count": 110,
"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": 111,
"id": "1d73a312",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.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_7584\\2261782218.py:9: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players[columns_to_copy[j]][i] = outfield_players[columns_to_copy[j]][fc_players['fb_ID'][i]]\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",
" "
]
},
{
"cell_type": "code",
"execution_count": 112,
"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": 112,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"keeper_players.columns[4:]"
]
},
{
"cell_type": "code",
"execution_count": 113,
"id": "eb9127a9",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.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_7584\\3664433845.py:11: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" fc_players[columns_to_copy[j]][i] = keeper_players[columns_to_copy[j]][fc_players['fb_ID'][i] - delta_k]\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]"
]
},
{
"cell_type": "code",
"execution_count": 114,
"id": "da977789",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" id | \n",
" r | \n",
" name | \n",
" team | \n",
" surname | \n",
" initial | \n",
" fb_ID | \n",
" age | \n",
" birth_year | \n",
" games | \n",
" ... | \n",
" gk_passes_length_avg | \n",
" gk_goal_kicks | \n",
" gk_pct_goal_kicks_launched | \n",
" gk_goal_kick_length_avg | \n",
" gk_crosses | \n",
" gk_crosses_stopped | \n",
" gk_crosses_stopped_pct | \n",
" gk_def_actions_outside_pen_area | \n",
" gk_def_actions_outside_pen_area_per90 | \n",
" gk_avg_distance_def_actions | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 572 | \n",
" P | \n",
" Meret | \n",
" Napoli | \n",
" Meret | \n",
" | \n",
" 535 | \n",
" 25-319 | \n",
" 1997 | \n",
" 0 | \n",
" ... | \n",
" 26.7 | \n",
" 118 | \n",
" 20.3 | \n",
" 27.5 | \n",
" 213 | \n",
" 6 | \n",
" 2.8 | \n",
" 24 | \n",
" 1.20 | \n",
" 17.2 | \n",
"
\n",
" \n",
" | 1 | \n",
" 2814 | \n",
" P | \n",
" Provedel | \n",
" Lazio | \n",
" Provedel | \n",
" | \n",
" 544 | \n",
" 28-324 | \n",
" 1994 | \n",
" 0 | \n",
" ... | \n",
" 32.8 | \n",
" 119 | \n",
" 33.6 | \n",
" 34.2 | \n",
" 266 | \n",
" 7 | \n",
" 2.6 | \n",
" 37 | \n",
" 1.86 | \n",
" 18.0 | \n",
"
\n",
" \n",
" | 2 | \n",
" 4964 | \n",
" P | \n",
" Vicario | \n",
" Empoli | \n",
" Vicario | \n",
" | \n",
" 553 | \n",
" 26-120 | \n",
" 1996 | \n",
" 0 | \n",
" ... | \n",
" 34.3 | \n",
" 107 | \n",
" 47.7 | \n",
" 42.5 | \n",
" 412 | \n",
" 25 | \n",
" 6.1 | \n",
" 10 | \n",
" 0.50 | \n",
" 10.7 | \n",
"
\n",
" \n",
" | 3 | \n",
" 453 | \n",
" P | \n",
" Szczesny | \n",
" Juventus | \n",
" Szczesny | \n",
" | \n",
" 550 | \n",
" 32-292 | \n",
" 1990 | \n",
" 0 | \n",
" ... | \n",
" 35.2 | \n",
" 62 | \n",
" 40.3 | \n",
" 38.9 | \n",
" 159 | \n",
" 4 | \n",
" 2.5 | \n",
" 10 | \n",
" 0.74 | \n",
" 15.1 | \n",
"
\n",
" \n",
" | 4 | \n",
" 2134 | \n",
" P | \n",
" Falcone | \n",
" Lecce | \n",
" Falcone | \n",
" | \n",
" 530 | \n",
" 27-298 | \n",
" 1995 | \n",
" 0 | \n",
" ... | \n",
" 40.9 | \n",
" 156 | \n",
" 75.0 | \n",
" 51.4 | \n",
" 302 | \n",
" 13 | \n",
" 4.3 | \n",
" 20 | \n",
" 1.00 | \n",
" 12.5 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 538 | \n",
" 5512 | \n",
" A | \n",
" De Luca | \n",
" Sampdoria | \n",
" Luca | \n",
" | \n",
" 130 | \n",
" 24-202 | \n",
" 1998 | \n",
" 1 | \n",
" ... | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 539 | \n",
" 5837 | \n",
" A | \n",
" Voelkerling Persson | \n",
" Lecce | \n",
" Persson | \n",
" | \n",
" 494 | \n",
" 20-020 | \n",
" 2003 | \n",
" 2 | \n",
" ... | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 540 | \n",
" 6113 | \n",
" A | \n",
" Montevago | \n",
" Sampdoria | \n",
" Montevago | \n",
" | \n",
" 322 | \n",
" 19-323 | \n",
" 2003 | \n",
" 6 | \n",
" ... | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 541 | \n",
" 6143 | \n",
" A | \n",
" Krollis | \n",
" Spezia | \n",
" Krollis | \n",
" | \n",
" -1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 542 | \n",
" 6160 | \n",
" A | \n",
" Vivaldo | \n",
" Udinese | \n",
" Vivaldo | \n",
" | \n",
" -1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0.0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
"
\n",
" \n",
"
\n",
"
543 rows × 167 columns
\n",
"
"
],
"text/plain": [
" id r name team surname initial fb_ID \\\n",
"0 572 P Meret Napoli Meret 535 \n",
"1 2814 P Provedel Lazio Provedel 544 \n",
"2 4964 P Vicario Empoli Vicario 553 \n",
"3 453 P Szczesny Juventus Szczesny 550 \n",
"4 2134 P Falcone Lecce Falcone 530 \n",
".. ... .. ... ... ... ... ... \n",
"538 5512 A De Luca Sampdoria Luca 130 \n",
"539 5837 A Voelkerling Persson Lecce Persson 494 \n",
"540 6113 A Montevago Sampdoria Montevago 322 \n",
"541 6143 A Krollis Spezia Krollis -1 \n",
"542 6160 A Vivaldo Udinese Vivaldo -1 \n",
"\n",
" age birth_year games ... gk_passes_length_avg gk_goal_kicks \\\n",
"0 25-319 1997 0 ... 26.7 118 \n",
"1 28-324 1994 0 ... 32.8 119 \n",
"2 26-120 1996 0 ... 34.3 107 \n",
"3 32-292 1990 0 ... 35.2 62 \n",
"4 27-298 1995 0 ... 40.9 156 \n",
".. ... ... ... ... ... ... \n",
"538 24-202 1998 1 ... 0.0 0 \n",
"539 20-020 2003 2 ... 0.0 0 \n",
"540 19-323 2003 6 ... 0.0 0 \n",
"541 0 0 0 ... 0.0 0 \n",
"542 0 0 0 ... 0.0 0 \n",
"\n",
" gk_pct_goal_kicks_launched gk_goal_kick_length_avg gk_crosses \\\n",
"0 20.3 27.5 213 \n",
"1 33.6 34.2 266 \n",
"2 47.7 42.5 412 \n",
"3 40.3 38.9 159 \n",
"4 75.0 51.4 302 \n",
".. ... ... ... \n",
"538 0.0 0.0 0 \n",
"539 0.0 0.0 0 \n",
"540 0.0 0.0 0 \n",
"541 0.0 0.0 0 \n",
"542 0.0 0.0 0 \n",
"\n",
" gk_crosses_stopped gk_crosses_stopped_pct \\\n",
"0 6 2.8 \n",
"1 7 2.6 \n",
"2 25 6.1 \n",
"3 4 2.5 \n",
"4 13 4.3 \n",
".. ... ... \n",
"538 0 0.0 \n",
"539 0 0.0 \n",
"540 0 0.0 \n",
"541 0 0.0 \n",
"542 0 0.0 \n",
"\n",
" gk_def_actions_outside_pen_area gk_def_actions_outside_pen_area_per90 \\\n",
"0 24 1.20 \n",
"1 37 1.86 \n",
"2 10 0.50 \n",
"3 10 0.74 \n",
"4 20 1.00 \n",
".. ... ... \n",
"538 0 0.00 \n",
"539 0 0.00 \n",
"540 0 0.00 \n",
"541 0 0.00 \n",
"542 0 0.00 \n",
"\n",
" gk_avg_distance_def_actions \n",
"0 17.2 \n",
"1 18.0 \n",
"2 10.7 \n",
"3 15.1 \n",
"4 12.5 \n",
".. ... \n",
"538 0.0 \n",
"539 0.0 \n",
"540 0.0 \n",
"541 0.0 \n",
"542 0.0 \n",
"\n",
"[543 rows x 167 columns]"
]
},
"execution_count": 114,
"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": 115,
"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": 116,
"id": "61fac91a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"vote_avg 6.217187\n",
"vote_std 0.440141\n",
"dtype: float64\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" vote_avg | \n",
" vote_std | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 6.275000 | \n",
" 0.486698 | \n",
"
\n",
" \n",
" | 1 | \n",
" 6.225000 | \n",
" 0.334477 | \n",
"
\n",
" \n",
" | 2 | \n",
" 6.450000 | \n",
" 0.384057 | \n",
"
\n",
" \n",
" | 3 | \n",
" 6.035714 | \n",
" 0.351745 | \n",
"
\n",
" \n",
" | 4 | \n",
" 6.325000 | \n",
" 0.363146 | \n",
"
\n",
" \n",
" | 5 | \n",
" 6.275000 | \n",
" 0.432290 | \n",
"
\n",
" \n",
" | 6 | \n",
" 6.000000 | \n",
" 0.447214 | \n",
"
\n",
" \n",
" | 7 | \n",
" 6.125000 | \n",
" 0.297560 | \n",
"
\n",
" \n",
" | 8 | \n",
" 6.366667 | \n",
" 0.426875 | \n",
"
\n",
" \n",
" | 9 | \n",
" 6.125000 | \n",
" 0.414578 | \n",
"
\n",
" \n",
" | 10 | \n",
" 6.153846 | \n",
" 0.302846 | \n",
"
\n",
" \n",
" | 11 | \n",
" 6.357143 | \n",
" 0.440315 | \n",
"
\n",
" \n",
" | 12 | \n",
" 6.363636 | \n",
" 0.642824 | \n",
"
\n",
" \n",
" | 13 | \n",
" 6.275000 | \n",
" 0.580409 | \n",
"
\n",
" \n",
" | 14 | \n",
" 6.300000 | \n",
" 0.458258 | \n",
"
\n",
" \n",
" | 15 | \n",
" 6.275000 | \n",
" 0.511737 | \n",
"
\n",
" \n",
" | 16 | \n",
" 6.150000 | \n",
" 0.502494 | \n",
"
\n",
" \n",
" | 17 | \n",
" 6.111111 | \n",
" 0.314270 | \n",
"
\n",
" \n",
" | 18 | \n",
" 6.194444 | \n",
" 0.412946 | \n",
"
\n",
" \n",
" | 19 | \n",
" 6.000000 | \n",
" 0.383482 | \n",
"
\n",
" \n",
" | 20 | \n",
" 5.884615 | \n",
" 0.348284 | \n",
"
\n",
" \n",
" | 21 | \n",
" 6.062500 | \n",
" 0.526634 | \n",
"
\n",
" \n",
" | 22 | \n",
" 6.071429 | \n",
" 0.494872 | \n",
"
\n",
" \n",
" | 23 | \n",
" 6.428571 | \n",
" 0.562429 | \n",
"
\n",
" \n",
" | 24 | \n",
" 6.600000 | \n",
" 0.583095 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" vote_avg vote_std\n",
"0 6.275000 0.486698\n",
"1 6.225000 0.334477\n",
"2 6.450000 0.384057\n",
"3 6.035714 0.351745\n",
"4 6.325000 0.363146\n",
"5 6.275000 0.432290\n",
"6 6.000000 0.447214\n",
"7 6.125000 0.297560\n",
"8 6.366667 0.426875\n",
"9 6.125000 0.414578\n",
"10 6.153846 0.302846\n",
"11 6.357143 0.440315\n",
"12 6.363636 0.642824\n",
"13 6.275000 0.580409\n",
"14 6.300000 0.458258\n",
"15 6.275000 0.511737\n",
"16 6.150000 0.502494\n",
"17 6.111111 0.314270\n",
"18 6.194444 0.412946\n",
"19 6.000000 0.383482\n",
"20 5.884615 0.348284\n",
"21 6.062500 0.526634\n",
"22 6.071429 0.494872\n",
"23 6.428571 0.562429\n",
"24 6.600000 0.583095"
]
},
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"min_votes = 6\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": 117,
"id": "c9312080",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" vote_avg | \n",
" vote_std | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 6.275000 | \n",
" 0.486698 | \n",
"
\n",
" \n",
" | 1 | \n",
" 6.225000 | \n",
" 0.334477 | \n",
"
\n",
" \n",
" | 2 | \n",
" 6.450000 | \n",
" 0.384057 | \n",
"
\n",
" \n",
" | 3 | \n",
" 6.035714 | \n",
" 0.351745 | \n",
"
\n",
" \n",
" | 4 | \n",
" 6.325000 | \n",
" 0.363146 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 538 | \n",
" 5.881660 | \n",
" 0.665426 | \n",
"
\n",
" \n",
" | 539 | \n",
" 6.227492 | \n",
" 0.259439 | \n",
"
\n",
" \n",
" | 540 | \n",
" 5.956291 | \n",
" 0.615163 | \n",
"
\n",
" \n",
" | 541 | \n",
" 5.699562 | \n",
" 0.705829 | \n",
"
\n",
" \n",
" | 542 | \n",
" 5.888111 | \n",
" 0.648879 | \n",
"
\n",
" \n",
"
\n",
"
543 rows × 2 columns
\n",
"
"
],
"text/plain": [
" vote_avg vote_std\n",
"0 6.275000 0.486698\n",
"1 6.225000 0.334477\n",
"2 6.450000 0.384057\n",
"3 6.035714 0.351745\n",
"4 6.325000 0.363146\n",
".. ... ...\n",
"538 5.881660 0.665426\n",
"539 6.227492 0.259439\n",
"540 5.956291 0.615163\n",
"541 5.699562 0.705829\n",
"542 5.888111 0.648879\n",
"\n",
"[543 rows x 2 columns]"
]
},
"execution_count": 117,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"min_votes = 6\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": 118,
"id": "b2570ce5",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" id | \n",
" r | \n",
" name | \n",
" team | \n",
" surname | \n",
" initial | \n",
" fb_ID | \n",
" age | \n",
" birth_year | \n",
" games | \n",
" ... | \n",
" gk_pct_goal_kicks_launched | \n",
" gk_goal_kick_length_avg | \n",
" gk_crosses | \n",
" gk_crosses_stopped | \n",
" gk_crosses_stopped_pct | \n",
" gk_def_actions_outside_pen_area | \n",
" gk_def_actions_outside_pen_area_per90 | \n",
" gk_avg_distance_def_actions | \n",
" vote_avg | \n",
" vote_std | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 572 | \n",
" P | \n",
" Meret | \n",
" Napoli | \n",
" Meret | \n",
" | \n",
" 535 | \n",
" 25-319 | \n",
" 1997 | \n",
" 0 | \n",
" ... | \n",
" 20.3 | \n",
" 27.5 | \n",
" 213 | \n",
" 6 | \n",
" 2.8 | \n",
" 24 | \n",
" 1.20 | \n",
" 17.2 | \n",
" 6.275000 | \n",
" 0.486698 | \n",
"
\n",
" \n",
" | 1 | \n",
" 2814 | \n",
" P | \n",
" Provedel | \n",
" Lazio | \n",
" Provedel | \n",
" | \n",
" 544 | \n",
" 28-324 | \n",
" 1994 | \n",
" 0 | \n",
" ... | \n",
" 33.6 | \n",
" 34.2 | \n",
" 266 | \n",
" 7 | \n",
" 2.6 | \n",
" 37 | \n",
" 1.86 | \n",
" 18.0 | \n",
" 6.225000 | \n",
" 0.334477 | \n",
"
\n",
" \n",
" | 2 | \n",
" 4964 | \n",
" P | \n",
" Vicario | \n",
" Empoli | \n",
" Vicario | \n",
" | \n",
" 553 | \n",
" 26-120 | \n",
" 1996 | \n",
" 0 | \n",
" ... | \n",
" 47.7 | \n",
" 42.5 | \n",
" 412 | \n",
" 25 | \n",
" 6.1 | \n",
" 10 | \n",
" 0.50 | \n",
" 10.7 | \n",
" 6.450000 | \n",
" 0.384057 | \n",
"
\n",
" \n",
" | 3 | \n",
" 453 | \n",
" P | \n",
" Szczesny | \n",
" Juventus | \n",
" Szczesny | \n",
" | \n",
" 550 | \n",
" 32-292 | \n",
" 1990 | \n",
" 0 | \n",
" ... | \n",
" 40.3 | \n",
" 38.9 | \n",
" 159 | \n",
" 4 | \n",
" 2.5 | \n",
" 10 | \n",
" 0.74 | \n",
" 15.1 | \n",
" 6.035714 | \n",
" 0.351745 | \n",
"
\n",
" \n",
" | 4 | \n",
" 2134 | \n",
" P | \n",
" Falcone | \n",
" Lecce | \n",
" Falcone | \n",
" | \n",
" 530 | \n",
" 27-298 | \n",
" 1995 | \n",
" 0 | \n",
" ... | \n",
" 75.0 | \n",
" 51.4 | \n",
" 302 | \n",
" 13 | \n",
" 4.3 | \n",
" 20 | \n",
" 1.00 | \n",
" 12.5 | \n",
" 6.325000 | \n",
" 0.363146 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 538 | \n",
" 5512 | \n",
" A | \n",
" De Luca | \n",
" Sampdoria | \n",
" Luca | \n",
" | \n",
" 130 | \n",
" 24-202 | \n",
" 1998 | \n",
" 1 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.881660 | \n",
" 0.665426 | \n",
"
\n",
" \n",
" | 539 | \n",
" 5837 | \n",
" A | \n",
" Voelkerling Persson | \n",
" Lecce | \n",
" Persson | \n",
" | \n",
" 494 | \n",
" 20-020 | \n",
" 2003 | \n",
" 2 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 6.227492 | \n",
" 0.259439 | \n",
"
\n",
" \n",
" | 540 | \n",
" 6113 | \n",
" A | \n",
" Montevago | \n",
" Sampdoria | \n",
" Montevago | \n",
" | \n",
" 322 | \n",
" 19-323 | \n",
" 2003 | \n",
" 6 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.956291 | \n",
" 0.615163 | \n",
"
\n",
" \n",
" | 541 | \n",
" 6143 | \n",
" A | \n",
" Krollis | \n",
" Spezia | \n",
" Krollis | \n",
" | \n",
" -1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.699562 | \n",
" 0.705829 | \n",
"
\n",
" \n",
" | 542 | \n",
" 6160 | \n",
" A | \n",
" Vivaldo | \n",
" Udinese | \n",
" Vivaldo | \n",
" | \n",
" -1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0 | \n",
" 0.0 | \n",
" 0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.888111 | \n",
" 0.648879 | \n",
"
\n",
" \n",
"
\n",
"
543 rows × 169 columns
\n",
"
"
],
"text/plain": [
" id r name team surname initial fb_ID \\\n",
"0 572 P Meret Napoli Meret 535 \n",
"1 2814 P Provedel Lazio Provedel 544 \n",
"2 4964 P Vicario Empoli Vicario 553 \n",
"3 453 P Szczesny Juventus Szczesny 550 \n",
"4 2134 P Falcone Lecce Falcone 530 \n",
".. ... .. ... ... ... ... ... \n",
"538 5512 A De Luca Sampdoria Luca 130 \n",
"539 5837 A Voelkerling Persson Lecce Persson 494 \n",
"540 6113 A Montevago Sampdoria Montevago 322 \n",
"541 6143 A Krollis Spezia Krollis -1 \n",
"542 6160 A Vivaldo Udinese Vivaldo -1 \n",
"\n",
" age birth_year games ... gk_pct_goal_kicks_launched \\\n",
"0 25-319 1997 0 ... 20.3 \n",
"1 28-324 1994 0 ... 33.6 \n",
"2 26-120 1996 0 ... 47.7 \n",
"3 32-292 1990 0 ... 40.3 \n",
"4 27-298 1995 0 ... 75.0 \n",
".. ... ... ... ... ... \n",
"538 24-202 1998 1 ... 0.0 \n",
"539 20-020 2003 2 ... 0.0 \n",
"540 19-323 2003 6 ... 0.0 \n",
"541 0 0 0 ... 0.0 \n",
"542 0 0 0 ... 0.0 \n",
"\n",
" gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n",
"0 27.5 213 6 \n",
"1 34.2 266 7 \n",
"2 42.5 412 25 \n",
"3 38.9 159 4 \n",
"4 51.4 302 13 \n",
".. ... ... ... \n",
"538 0.0 0 0 \n",
"539 0.0 0 0 \n",
"540 0.0 0 0 \n",
"541 0.0 0 0 \n",
"542 0.0 0 0 \n",
"\n",
" gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n",
"0 2.8 24 \n",
"1 2.6 37 \n",
"2 6.1 10 \n",
"3 2.5 10 \n",
"4 4.3 20 \n",
".. ... ... \n",
"538 0.0 0 \n",
"539 0.0 0 \n",
"540 0.0 0 \n",
"541 0.0 0 \n",
"542 0.0 0 \n",
"\n",
" gk_def_actions_outside_pen_area_per90 gk_avg_distance_def_actions \\\n",
"0 1.20 17.2 \n",
"1 1.86 18.0 \n",
"2 0.50 10.7 \n",
"3 0.74 15.1 \n",
"4 1.00 12.5 \n",
".. ... ... \n",
"538 0.00 0.0 \n",
"539 0.00 0.0 \n",
"540 0.00 0.0 \n",
"541 0.00 0.0 \n",
"542 0.00 0.0 \n",
"\n",
" vote_avg vote_std \n",
"0 6.275000 0.486698 \n",
"1 6.225000 0.334477 \n",
"2 6.450000 0.384057 \n",
"3 6.035714 0.351745 \n",
"4 6.325000 0.363146 \n",
".. ... ... \n",
"538 5.881660 0.665426 \n",
"539 6.227492 0.259439 \n",
"540 5.956291 0.615163 \n",
"541 5.699562 0.705829 \n",
"542 5.888111 0.648879 \n",
"\n",
"[543 rows x 169 columns]"
]
},
"execution_count": 118,
"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": 119,
"id": "f7620abe",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'ball_recoveries'"
]
},
"execution_count": 119,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fc_players.columns[123]"
]
},
{
"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": 120,
"id": "700b7a7d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zoet, 0.5\n",
"Ochoa, 0.8333333333333334\n",
"Pegolo, 0.33333333333333337\n",
"Gollini, 0.5\n",
"Mirante, 0.0\n",
"Sarr M., 0.0\n",
"Lamanna, 0.0\n",
"Ujkani, 0.0\n",
"Berisha, 0.0\n",
"Marchetti, 0.0\n",
"Perilli, 0.0\n",
"Padelli, 0.0\n",
"Perisan, 0.0\n",
"Bardi, 0.0\n",
"Cordaz, 0.0\n",
"Pinsoglio, 0.0\n",
"Fiorillo, 0.0\n",
"Cragno, 0.0\n",
"Sirigu, 0.0\n",
"Cerofolini, 0.0\n",
"Rossi F., 0.0\n",
"Ravaglia F., 0.0\n",
"Brancolini, 0.0\n",
"Bleve, 0.0\n",
"Berardi A., 0.0\n",
"Russo A., 0.0\n",
"Gemello, 0.0\n",
"Ravaglia, 0.0\n",
"Boer, 0.0\n",
"Adamonis, 0.0\n",
"Marfella, 0.0\n",
"Zovko, 0.16666666666666663\n",
"Piana, 0.0\n",
"Bagnolini, 0.0\n",
"Luis Maximiano, 0.16666666666666663\n",
"Svilar, 0.0\n",
"Sorrentino A., 0.0\n",
"Ciezkowski, 0.0\n",
"Saro, 0.0\n",
"Vasquez D., 0.0\n",
"Turk, 0.0\n"
]
}
],
"source": [
"min_gk_games = 6\n",
"\n",
"fc_players_newgk = fc_players.copy()\n",
"\n",
"columns_to_avg = fc_players.columns[123:] # 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": 121,
"id": "2d9eee99",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" id | \n",
" r | \n",
" name | \n",
" team | \n",
" surname | \n",
" initial | \n",
" fb_ID | \n",
" age | \n",
" birth_year | \n",
" games | \n",
" ... | \n",
" gk_pct_goal_kicks_launched | \n",
" gk_goal_kick_length_avg | \n",
" gk_crosses | \n",
" gk_crosses_stopped | \n",
" gk_crosses_stopped_pct | \n",
" gk_def_actions_outside_pen_area | \n",
" gk_def_actions_outside_pen_area_per90 | \n",
" gk_avg_distance_def_actions | \n",
" vote_avg | \n",
" vote_std | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 572 | \n",
" P | \n",
" Meret | \n",
" Napoli | \n",
" Meret | \n",
" | \n",
" 535 | \n",
" 25-319 | \n",
" 1997 | \n",
" 0 | \n",
" ... | \n",
" 20.3 | \n",
" 27.5 | \n",
" 213.0 | \n",
" 6.0 | \n",
" 2.8 | \n",
" 24.0 | \n",
" 1.20 | \n",
" 17.2 | \n",
" 6.275000 | \n",
" 0.486698 | \n",
"
\n",
" \n",
" | 1 | \n",
" 2814 | \n",
" P | \n",
" Provedel | \n",
" Lazio | \n",
" Provedel | \n",
" | \n",
" 544 | \n",
" 28-324 | \n",
" 1994 | \n",
" 0 | \n",
" ... | \n",
" 33.6 | \n",
" 34.2 | \n",
" 266.0 | \n",
" 7.0 | \n",
" 2.6 | \n",
" 37.0 | \n",
" 1.86 | \n",
" 18.0 | \n",
" 6.225000 | \n",
" 0.334477 | \n",
"
\n",
" \n",
" | 2 | \n",
" 4964 | \n",
" P | \n",
" Vicario | \n",
" Empoli | \n",
" Vicario | \n",
" | \n",
" 553 | \n",
" 26-120 | \n",
" 1996 | \n",
" 0 | \n",
" ... | \n",
" 47.7 | \n",
" 42.5 | \n",
" 412.0 | \n",
" 25.0 | \n",
" 6.1 | \n",
" 10.0 | \n",
" 0.50 | \n",
" 10.7 | \n",
" 6.450000 | \n",
" 0.384057 | \n",
"
\n",
" \n",
" | 3 | \n",
" 453 | \n",
" P | \n",
" Szczesny | \n",
" Juventus | \n",
" Szczesny | \n",
" | \n",
" 550 | \n",
" 32-292 | \n",
" 1990 | \n",
" 0 | \n",
" ... | \n",
" 40.3 | \n",
" 38.9 | \n",
" 159.0 | \n",
" 4.0 | \n",
" 2.5 | \n",
" 10.0 | \n",
" 0.74 | \n",
" 15.1 | \n",
" 6.035714 | \n",
" 0.351745 | \n",
"
\n",
" \n",
" | 4 | \n",
" 2134 | \n",
" P | \n",
" Falcone | \n",
" Lecce | \n",
" Falcone | \n",
" | \n",
" 530 | \n",
" 27-298 | \n",
" 1995 | \n",
" 0 | \n",
" ... | \n",
" 75.0 | \n",
" 51.4 | \n",
" 302.0 | \n",
" 13.0 | \n",
" 4.3 | \n",
" 20.0 | \n",
" 1.00 | \n",
" 12.5 | \n",
" 6.325000 | \n",
" 0.363146 | \n",
"
\n",
" \n",
" | ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" | 538 | \n",
" 5512 | \n",
" A | \n",
" De Luca | \n",
" Sampdoria | \n",
" Luca | \n",
" | \n",
" 130 | \n",
" 24-202 | \n",
" 1998 | \n",
" 1 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.881660 | \n",
" 0.665426 | \n",
"
\n",
" \n",
" | 539 | \n",
" 5837 | \n",
" A | \n",
" Voelkerling Persson | \n",
" Lecce | \n",
" Persson | \n",
" | \n",
" 494 | \n",
" 20-020 | \n",
" 2003 | \n",
" 2 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 6.227492 | \n",
" 0.259439 | \n",
"
\n",
" \n",
" | 540 | \n",
" 6113 | \n",
" A | \n",
" Montevago | \n",
" Sampdoria | \n",
" Montevago | \n",
" | \n",
" 322 | \n",
" 19-323 | \n",
" 2003 | \n",
" 6 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.956291 | \n",
" 0.615163 | \n",
"
\n",
" \n",
" | 541 | \n",
" 6143 | \n",
" A | \n",
" Krollis | \n",
" Spezia | \n",
" Krollis | \n",
" | \n",
" -1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.699562 | \n",
" 0.705829 | \n",
"
\n",
" \n",
" | 542 | \n",
" 6160 | \n",
" A | \n",
" Vivaldo | \n",
" Udinese | \n",
" Vivaldo | \n",
" | \n",
" -1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
" 0.00 | \n",
" 0.0 | \n",
" 5.888111 | \n",
" 0.648879 | \n",
"
\n",
" \n",
"
\n",
"
543 rows × 169 columns
\n",
"
"
],
"text/plain": [
" id r name team surname initial fb_ID \\\n",
"0 572 P Meret Napoli Meret 535 \n",
"1 2814 P Provedel Lazio Provedel 544 \n",
"2 4964 P Vicario Empoli Vicario 553 \n",
"3 453 P Szczesny Juventus Szczesny 550 \n",
"4 2134 P Falcone Lecce Falcone 530 \n",
".. ... .. ... ... ... ... ... \n",
"538 5512 A De Luca Sampdoria Luca 130 \n",
"539 5837 A Voelkerling Persson Lecce Persson 494 \n",
"540 6113 A Montevago Sampdoria Montevago 322 \n",
"541 6143 A Krollis Spezia Krollis -1 \n",
"542 6160 A Vivaldo Udinese Vivaldo -1 \n",
"\n",
" age birth_year games ... gk_pct_goal_kicks_launched \\\n",
"0 25-319 1997 0 ... 20.3 \n",
"1 28-324 1994 0 ... 33.6 \n",
"2 26-120 1996 0 ... 47.7 \n",
"3 32-292 1990 0 ... 40.3 \n",
"4 27-298 1995 0 ... 75.0 \n",
".. ... ... ... ... ... \n",
"538 24-202 1998 1 ... 0.0 \n",
"539 20-020 2003 2 ... 0.0 \n",
"540 19-323 2003 6 ... 0.0 \n",
"541 0 0 0 ... 0.0 \n",
"542 0 0 0 ... 0.0 \n",
"\n",
" gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n",
"0 27.5 213.0 6.0 \n",
"1 34.2 266.0 7.0 \n",
"2 42.5 412.0 25.0 \n",
"3 38.9 159.0 4.0 \n",
"4 51.4 302.0 13.0 \n",
".. ... ... ... \n",
"538 0.0 0.0 0.0 \n",
"539 0.0 0.0 0.0 \n",
"540 0.0 0.0 0.0 \n",
"541 0.0 0.0 0.0 \n",
"542 0.0 0.0 0.0 \n",
"\n",
" gk_crosses_stopped_pct gk_def_actions_outside_pen_area \\\n",
"0 2.8 24.0 \n",
"1 2.6 37.0 \n",
"2 6.1 10.0 \n",
"3 2.5 10.0 \n",
"4 4.3 20.0 \n",
".. ... ... \n",
"538 0.0 0.0 \n",
"539 0.0 0.0 \n",
"540 0.0 0.0 \n",
"541 0.0 0.0 \n",
"542 0.0 0.0 \n",
"\n",
" gk_def_actions_outside_pen_area_per90 gk_avg_distance_def_actions \\\n",
"0 1.20 17.2 \n",
"1 1.86 18.0 \n",
"2 0.50 10.7 \n",
"3 0.74 15.1 \n",
"4 1.00 12.5 \n",
".. ... ... \n",
"538 0.00 0.0 \n",
"539 0.00 0.0 \n",
"540 0.00 0.0 \n",
"541 0.00 0.0 \n",
"542 0.00 0.0 \n",
"\n",
" vote_avg vote_std \n",
"0 6.275000 0.486698 \n",
"1 6.225000 0.334477 \n",
"2 6.450000 0.384057 \n",
"3 6.035714 0.351745 \n",
"4 6.325000 0.363146 \n",
".. ... ... \n",
"538 5.881660 0.665426 \n",
"539 6.227492 0.259439 \n",
"540 5.956291 0.615163 \n",
"541 5.699562 0.705829 \n",
"542 5.888111 0.648879 \n",
"\n",
"[543 rows x 169 columns]"
]
},
"execution_count": 121,
"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": 122,
"id": "8336c025",
"metadata": {},
"outputs": [],
"source": [
"fc_players.to_excel('mid_outputs/players_stats.xlsx')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f3fc9b1b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}