{ "cells": [ { "cell_type": "markdown", "id": "b2cd2177", "metadata": {}, "source": [ "Players dataset creation\n", "\n", "The Fantacalcio players list is manually downloaded from https://www.fantacalcio.it/quotazioni-fantacalcio\n", "\n", "Here, the players database is generated, by merging the Fantacalcio list to stats downloaded from http://fbref.com" ] }, { "cell_type": "code", "execution_count": 1, "id": "7c65df92", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "id": "5ab35d0c", "metadata": {}, "source": [ "Load fbref data for outfield players and goalkeepers.\n", "\n", "Generate fbref player list, adding player surname (with special characters replaced to normal ones)" ] }, { "cell_type": "code", "execution_count": 2, "id": "b2d7073e", "metadata": {}, "outputs": [], "source": [ "rcsv = pd.read_csv('fbref_data/outfield_players.csv') \n", "outfield_players = pd.DataFrame(rcsv)\n", "\n", "rcsv = pd.read_csv('fbref_data/keepers_players.csv') \n", "keeper_players = pd.DataFrame(rcsv)" ] }, { "cell_type": "code", "execution_count": 3, "id": "667970f6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
playerteam
0James AbankwahUdinese
1Oliver AbildgaardHellas Verona
2Tammy AbrahamRoma
3Christian AcellaCremonese
4Francesco AcerbiInter
.........
615Pietro TerraccianoFiorentina
616Martin TurkSampdoria
617Guglielmo VicarioEmpoli
618Jeroen ZoetSpezia
619Petar ZovkoSpezia
\n", "

620 rows × 2 columns

\n", "
" ], "text/plain": [ " player team\n", "0 James Abankwah Udinese\n", "1 Oliver Abildgaard Hellas Verona\n", "2 Tammy Abraham Roma\n", "3 Christian Acella Cremonese\n", "4 Francesco Acerbi Inter\n", ".. ... ...\n", "615 Pietro Terracciano Fiorentina\n", "616 Martin Turk Sampdoria\n", "617 Guglielmo Vicario Empoli\n", "618 Jeroen Zoet Spezia\n", "619 Petar Zovko Spezia\n", "\n", "[620 rows x 2 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "players = pd.concat( [ outfield_players[['player', 'team']], keeper_players[['player', 'team']] ], axis = 0, ignore_index = True)\n", "\n", "keepers_ID = len(outfield_players)\n", "\n", "players" ] }, { "cell_type": "code", "execution_count": 4, "id": "e1e64596", "metadata": {}, "outputs": [], "source": [ "import unicodedata\n", "\n", "def normalize_name(input_str):\n", " nfkd_form = unicodedata.normalize('NFKD', input_str)\n", " only_ascii = nfkd_form.encode('ASCII', 'ignore')\n", " return only_ascii.decode('utf-8')" ] }, { "cell_type": "code", "execution_count": 5, "id": "3078d6f3", "metadata": {}, "outputs": [], "source": [ "players['surname'] = players['player']\n", "players['initial'] = players['player']\n", "\n", "for i in range(players.shape[0]):\n", " players['surname'][i] = players['surname'][i].split(' ')[-1]\n", " players['surname'][i] = normalize_name(players['surname'][i]).replace('\\'', '')\n", " \n", " \n", " players['initial'][i] = players['player'][i][0]" ] }, { "cell_type": "code", "execution_count": 6, "id": "ffd6091c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " player surname\n", "0 James Abankwah Abankwah\n", "1 Oliver Abildgaard Abildgaard\n", "2 Tammy Abraham Abraham\n", "3 Christian Acella Acella\n", "4 Francesco Acerbi Acerbi\n", "5 Yacine Adli Adli\n", "6 Michel Aebischer Aebischer\n", "7 Felix Afena-Gyan Afena-Gyan\n", "8 Kevin Agudelo Agudelo\n", "9 Ola Aina Aina\n", "10 Emanuel Aiwum Aiwum\n", "11 Jean-Daniel Akpa-Akpro Akpa-Akpro\n", "12 Luis Alberto Alberto\n", "13 Agustín Álvarez Martínez Martinez\n", "14 Kelvin Amian Amian\n", "15 Bruno Amione Amione\n", "16 Bruno Amione Amione\n", "17 Ethan Ampadu Ampadu\n", "18 Sofyan Amrabat Amrabat\n", "19 Felipe Anderson Anderson\n", "20 Janis Antiste Antiste\n", "21 Marcos Antônio Antonio\n", "22 Valentin Antov Antov\n", "23 Marko Arnautović Arnautovic\n", "24 Tolgay Arslan Arslan\n", "25 Arthur Arthur\n", "26 Santiago Ascacíbar Ascacibar\n", "27 Kristoffer Askildsen Askildsen\n", "28 Kristjan Asllani Asllani\n", "29 Emil Audero Audero\n", "30 Tommaso Augello Augello\n", "31 Kaan Ayhan Ayhan\n", "32 Jaime Báez Baez\n", "33 Nedim Bajrami Bajrami\n", "34 Nedim Bajrami Bajrami\n", "35 Tiemoué Bakayoko Bakayoko\n", "36 Tommaso Baldanzi Baldanzi\n", "37 Fodé Ballo-Touré Ballo-Toure\n", "38 Lameck Banda Banda\n", "39 Filippo Bandinelli Bandinelli\n", "40 Antonín Barák Barak\n", "41 Antonín Barák Barak\n", "42 Andrea Barberis Barberis\n", "43 Tommaso Barbieri Barbieri\n", "44 Francesco Bardi Bardi\n", "45 Nicolò Barella Barella\n", "46 Enzo Barrenechea Barrenechea\n", "47 Musa Barrow Barrow\n", "48 Federico Baschirotto Baschirotto\n", "49 Toma Bašić Basic\n", "50 Alberto Basso Basso\n", "51 Alessandro Bastoni Bastoni\n", "52 Simone Bastoni Bastoni\n", "53 Brian Bayeye Bayeye\n", "54 Rodrigo Becão Becao\n", "55 Julius Beck Beck\n", "56 Raoul Bellanova Bellanova\n", "57 Andrea Belotti Belotti\n", "58 Marco Benassi Benassi\n", "59 Marco Benassi Benassi\n", "60 Ismaël Bennacer Bennacer\n", "61 Domenico Berardi Berardi\n", "62 Bartosz Bereszyński Bereszynski\n", "63 Beto Beto\n", "64 Matteo Bianchetti Bianchetti\n", "65 Alessandro Bianco Bianco\n", "66 Jaka Bijol Bijol\n", "67 Cristiano Biraghi Biraghi\n", "68 Samuele Birindelli Birindelli\n", "69 Kristijan Bistrović Bistrovic\n", "70 Alexis Blin Blin\n", "71 Jeremie Boga Boga\n", "72 Emil Bohinen Bohinen\n", "73 Giacomo Bonaventura Bonaventura\n", "74 Federico Bonazzoli Bonazzoli\n", "75 Warren Bondo Bondo\n", "76 Kevin Bonifazi Bonifazi\n", "77 Leonardo Bonucci Bonucci\n", "78 Erik Botheim Botheim\n", "79 Mehdi Bourabia Bourabia\n", "80 Edoardo Bove Bove\n", "81 Jayden Braaf Braaf\n", "82 Domagoj Bradarić Bradaric\n", "83 Josip Brekalo Brekalo\n", "84 Gleison Bremer Bremer\n", "85 Dylan Bronn Bronn\n", "86 Marcelo Brozović Brozovic\n", "87 Cristian Buonaiuto Buonaiuto\n", "88 Alessandro Buongiorno Buongiorno\n", "89 Juan Cabal Cabal\n", "90 Liberato Cacace Cacace\n", "91 Davide Calabria Calabria\n", "92 Mattia Caldara Caldara\n", "93 Luca Caldirola Caldirola\n", "94 Hakan Çalhanoğlu Calhanoglu\n", "95 Mohamed Camara Camara\n", "96 Nicolò Cambiaghi Cambiaghi\n", "97 Andrea Cambiaso Cambiaso\n", "98 Matteo Cancellieri Cancellieri\n", "99 Antonio Candreva Candreva\n", "100 Gianluca Caprari Caprari\n", "101 Francesco Caputo Caputo\n", "102 Francesco Caputo Caputo\n", "103 Andrea Carboni Carboni\n", "104 Franco Carboni Carboni\n", "105 Valentin Carboni Carboni\n", "106 Carlos Carlos\n", "107 Marco Carnesecchi Carnesecchi\n", "108 Nicolò Casale Casale\n", "109 Tommaso Cassandro Cassandro\n", "110 Michele Castagnetti Castagnetti\n", "111 Gaetano Castrovilli Castrovilli\n", "112 Danilo Cataldi Cataldi\n", "113 Pietro Ceccaroni Ceccaroni\n", "114 Federico Ceccherini Ceccherini\n", "115 Assan Ceesay Ceesay\n", "116 Emil Ceide Ceide\n", "117 Zeki Çelik Celik\n", "118 Federico Chiesa Chiesa\n", "119 Vlad Chiricheș Chiriches\n", "120 Daniel Ciofani Ciofani\n", "121 Tio Cipot Cipot\n", "122 Patrick Ciurria Ciurria\n", "123 Omar Colley Colley\n", "124 Lorenzo Colombo Colombo\n", "125 Andrea Colpani Colpani\n", "126 Andrea Consigli Consigli\n", "127 Andrea Conti Conti\n", "128 Diego Coppola Coppola\n", "129 Joaquín Correa Correa\n", "130 Alessandro Cortinovis Cortinovis\n", "131 Lassana Coulibaly Coulibaly\n", "132 Alessio Cragno Cragno\n", "133 Bryan Cristante Cristante\n", "134 Domen Črnigoj Crnigoj\n", "135 Juan Cuadrado Cuadrado\n", "136 Mickaël Cuisance Cuisance\n", "137 Marco D'Alessandro DAlessandro\n", "138 Danilo D'Ambrosio DAmbrosio\n", "139 Luca D'Andrea DAndrea\n", "140 Flavius Daniliuc Daniliuc\n", "141 Danilo Danilo\n", "142 Matteo Darmian Darmian\n", "143 Paweł Dawidowicz Dawidowicz\n", "144 Charles De Ketelaere Ketelaere\n", "145 Manuel De Luca Luca\n", "146 Mattia De Sciglio Sciglio\n", "147 Lorenzo De Silvestri Silvestri\n", "148 Koni De Winter Winter\n", "149 Grégoire Defrel Defrel\n", "150 Duccio Degl'Innocenti DeglInnocenti\n", "151 Merih Demiral Demiral\n", "152 Diego Demme Demme\n", "153 Fabio Depaoli Depaoli\n", "154 Fabio Depaoli Depaoli\n", "155 Kastriot Dermaku Dermaku\n", "156 Cyriel Dessers Dessers\n", "157 Sergiño Dest Dest\n", "158 Mattia Destro Destro\n", "159 Gerard Deulofeu Deulofeu\n", "160 Samuel Di Carmine Carmine\n", "161 Federico Di Francesco Francesco\n", "162 Michele Di Gregorio Gregorio\n", "163 Giovanni Di Lorenzo Lorenzo\n", "164 Ángel Di María Maria\n", "165 Boulaye Dia Dia\n", "166 Brahim Díaz Diaz\n", "167 Federico Dimarco Dimarco\n", "168 Koffi Djidji Djidji\n", "169 Berat Djimsiti Djimsiti\n", "170 Dodô Dodo\n", "171 Josh Doig Doig\n", "172 Nicolás Domínguez Dominguez\n", "173 Giulio Donati Donati\n", "174 Bartłomiej Drągowski Dragowski\n", "175 Ondrej Duda Duda\n", "176 Denzel Dumfries Dumfries\n", "177 Alfred Duncan Duncan\n", "178 Paulo Dybala Dybala\n", "179 Edin Džeko Dzeko\n", "180 Festy Ebosele Ebosele\n", "181 Enzo Ebosse Ebosse\n", "182 Tyronne Ebuehi Ebuehi\n", "183 Éderson Ederson\n", "184 Kingsley Ehizibue Ehizibue\n", "185 Albin Ekdal Ekdal\n", "186 Emmanuel Ekong Ekong\n", "187 Mikael Ellertsson Ellertsson\n", "188 Elif Elmas Elmas\n", "189 Martin Erlic Erlic\n", "190 Gonzalo Escalante Escalante\n", "191 Salvatore Esposito Esposito\n", "192 Nicolò Fagioli Fagioli\n", "193 Wladimiro Falcone Falcone\n", "194 Davide Faraoni Faraoni\n", "195 Federico Fazio Fazio\n", "196 Jacopo Fazzini Fazzini\n", "197 Lewis Ferguson Ferguson\n", "198 Alex Ferrari Ferrari\n", "199 Alex Ferrari Ferrari\n", "200 Salvador Ferrer Ferrer\n", "201 Alessandro Florenzi Florenzi\n", "202 Davide Frattesi Frattesi\n", "203 Matteo Gabbia Gabbia\n", "204 Manolo Gabbiadini Gabbiadini\n", "205 Gianluca Gaetano Gaetano\n", "206 Roberto Gagliardini Gagliardini\n", "207 Adolfo Gaich Gaich\n", "208 Pablo Galdames Millán Millan\n", "209 Antonino Gallo Gallo\n", "210 Federico Gatti Gatti\n", "211 Valentin Gendrey Gendrey\n", "212 Paolo Ghiglione Ghiglione\n", "213 Mario Gila Gila\n", "214 Gvidas Gineitis Gineitis\n", "215 Olivier Giroud Giroud\n", "216 Pierluigi Gollini Gollini\n", "217 Pierluigi Gollini Gollini\n", "218 Joan Gonzàlez Gonzalez\n", "219 Nicolás González Gonzalez\n", "220 Robin Gosens Gosens\n", "221 Alberto Grassi Grassi\n", "222 Andrew Gravillon Gravillon\n", "223 Koray Günter Gunter\n", "224 Koray Günter Gunter\n", "225 Emmanuel Gyasi Gyasi\n", "226 Norbert Gyömbér Gyomber\n", "227 Christian Gytkjær Gytkjr\n", "228 Nicolas Haas Haas\n", "229 Samir Handanović Handanovic\n", "230 Abdou Harroui Harroui\n", "231 Hans Hateboer Hateboer\n", "232 Liam Henderson Henderson\n", "233 Jack Hendry Hendry\n", "234 Matheus Henrique Henrique\n", "235 Thomas Henry Henry\n", "236 Theo Hernández Hernandez\n", "237 Isak Hien Hien\n", "238 Morten Hjulmand Hjulmand\n", "239 Emil Holm Holm\n", "240 Martin Hongla Hongla\n", "241 Petko Hristov Hristov\n", "242 Ajdin Hrustic Hrustic\n", "243 Elseid Hysaj Hysaj\n", "244 Rasmus Højlund Hjlund\n", "245 Roger Ibanez Ibanez\n", "246 Zlatan Ibrahimović Ibrahimovic\n", "247 Igor Igor\n", "248 Jonathan Ikone Ikone\n", "249 Ivan Ilić Ilic\n", "250 Ivan Ilić Ilic\n", "251 Samuel Iling-Junior Iling-Junior\n", "252 Emirhan İlkhan Ilkhan\n", "253 Emirhan İlkhan Ilkhan\n", "254 Ciro Immobile Immobile\n", "255 Ardian Ismajli Ismajli\n", "256 Armando Izzo Izzo\n", "257 Mato Jajalo Jajalo\n", "258 Jesé Jese\n", "259 Juan Jesus Jesus\n", "260 Þórir Jóhann Helgason Helgason\n", "261 Luka Jović Jovic\n", "262 Hamed Junior Traorè Traore\n", "263 Yayah Kallon Kallon\n", "264 Pierre Kalulu Kalulu\n", "265 Yann Karamoh Karamoh\n", "266 Rick Karsdorp Karsdorp\n", "267 Denso Kasius Kasius\n", "268 Grigoris Kastanos Kastanos\n", "269 Moise Kean Kean\n", "270 Jakub Kiwior Kiwior\n", "271 Simon Kjær Kjr\n", "272 Teun Koopmeiners Koopmeiners\n", "273 Filip Kostić Kostic\n", "274 Christian Kouamé Kouame\n", "275 Viktor Kovalenko Kovalenko\n", "276 Julian Kristoffersen Kristoffersen\n", "277 Raimonds Krollis Krollis\n", "278 Rade Krunić Krunic\n", "279 Marash Kumbulla Kumbulla\n", "280 Khvicha Kvaratskhelia Kvaratskhelia\n", "281 Giorgos Kyriakopoulos Kyriakopoulos\n", "282 Giorgos Kyriakopoulos Kyriakopoulos\n", "283 Sam Lammers Lammers\n", "284 Sam Lammers Lammers\n", "285 Kevin Lasagna Lasagna\n", "286 Armand Lauriente Lauriente\n", "287 Valentino Lazaro Lazaro\n", "288 Marko Lazetić Lazetic\n", "289 Darko Lazović Lazovic\n", "290 Manuel Lazzari Lazzari\n", "291 Rafael Leão Leao\n", "292 Mehdi Léris Leris\n", "293 Karol Linetty Linetty\n", "294 Marcin Listkowski Listkowski\n", "295 Diego Llorente Llorente\n", "296 Stanislav Lobotka Lobotka\n", "297 Manuel Locatelli Locatelli\n", "298 Luka Lochoshvili Lochoshvili\n", "299 Ademola Lookman Lookman\n", "300 Maxime Lopez Lopez\n", "301 Matteo Lovato Lovato\n", "302 Sandi Lovrić Lovric\n", "303 Hirving Lozano Lozano\n", "304 Jhon Lucumí Lucumi\n", "305 José Luis Palomino Palomino\n", "306 Romelu Lukaku Lukaku\n", "307 Saša Lukić Lukic\n", "308 Sebastiano Luperto Luperto\n", "309 Charalambos Lykogiannis Lykogiannis\n", "310 Giulio Maggiore Maggiore\n", "311 Giangiacomo Magnani Magnani\n", "312 Mike Maignan Maignan\n", "313 Jordan Majchrzak Majchrzak\n", "314 Jean-Victor Makengo Makengo\n", "315 Lorenzo Malagrida Malagrida\n", "316 Daniel Maldini Maldini\n", "317 Youssef Maleh Maleh\n", "318 Youssef Maleh Maleh\n", "319 Ruslan Malinovskyi Malinovskyi\n", "320 Gianluca Mancini Mancini\n", "321 Rolando Mandragora Mandragora\n", "322 Federico Marchetti Marchetti\n", "323 Riccardo Marchizza Marchizza\n", "324 Gian Marco Ferrari Ferrari\n", "325 Pablo Marí Mari\n", "326 Răzvan Marin Marin\n", "327 Marlon Marlon\n", "328 Luca Marrone Marrone\n", "329 Lautaro Martínez Martinez\n", "330 Lucas Martínez Quarta Quarta\n", "331 Adam Marušić Marusic\n", "332 Adam Masina Masina\n", "333 Nemanja Matić Matic\n", "334 Luís Maximiano Maximiano\n", "335 Pasquale Mazzocchi Mazzocchi\n", "336 Weston McKennie McKennie\n", "337 Gary Medel Medel\n", "338 Soualiho Meïté Meite\n", "339 Alex Meret Meret\n", "340 Yıldırım Mert Çetin Cetin\n", "341 Junior Messias Messias\n", "342 Tommaso Milanese Milanese\n", "343 Nikola Milenković Milenkovic\n", "344 Arkadiusz Milik Milik\n", "345 Sergej Milinković-Savić Milinkovic-Savic\n", "346 Vanja Milinković-Savić Milinkovic-Savic\n", "347 Kim Min-jae Min-jae\n", "348 Aleksei Miranchuk Miranchuk\n", "349 Fabio Miretti Miretti\n", "350 Henrikh Mkhitaryan Mkhitaryan\n", "351 Salvatore Molina Molina\n", "352 Daniele Montevago Montevago\n", "353 Lorenzo Montipò Montipo\n", "354 Nikola Moro Moro\n", "355 Dany Mota Mota\n", "356 João Moutinho Moutinho\n", "357 Mert Müldür Muldur\n", "358 Luis Muriel Muriel\n", "359 Jeison Murillo Murillo\n", "360 Nicola Murru Murru\n", "361 Juan Musso Musso\n", "362 Joakim Mæhle Mhle\n", "363 Herculano Nabian Nabian\n", "364 Michel Ndary Adopo Adopo\n", "365 Tanguy Ndombele Ndombele\n", "366 Ilija Nestorovski Nestorovski\n", "367 Cyril Ngonge Ngonge\n", "368 Hans Nicolussi Caviglia Caviglia\n", "369 Dimitris Nikolaou Nikolaou\n", "370 Bram Nuytinck Nuytinck\n", "371 Bram Nuytinck Nuytinck\n", "372 M'Bala Nzola Nzola\n", "373 Pedro Obiang Obiang\n", "374 Guillermo Ochoa Ochoa\n", "375 Marios Oikonomou Oikonomou\n", "376 David Okereke Okereke\n", "377 Caleb Okoli Okoli\n", "378 Mathías Olivera Olivera\n", "379 André Onana Onana\n", "380 Divock Origi Origi\n", "381 Riccardo Orsolini Orsolini\n", "382 Victor Osimhen Osimhen\n", "383 Remi Oudin Oudin\n", "384 Adam Ounas Ounas\n", "385 Simone Pafundi Pafundi\n", "386 Flavio Paoletti Paoletti\n", "387 Leandro Paredes Paredes\n", "388 Fabiano Parisi Parisi\n", "389 Mario Pašalić Pasalic\n", "390 Patric Patric\n", "391 Rui Patrício Patricio\n", "392 Pedro Pedro\n", "393 Gianluca Pegolo Pegolo\n", "394 Pietro Pellegri Pellegri\n", "395 Lorenzo Pellegrini Pellegrini\n", "396 Luca Pellegrini Pellegrini\n", "397 Pepín Pepin\n", "398 Roberto Pereyra Pereyra\n", "399 Nehuén Pérez Perez\n", "400 Simone Perilli Perilli\n", "401 Mattia Perin Perin\n", "402 Samuele Perisan Perisan\n", "403 Matteo Pessina Pessina\n", "404 Andrea Petagna Petagna\n", "405 Giuseppe Pezzella Pezzella\n", "406 Krzysztof Piątek Piatek\n", "407 Roberto Piccoli Piccoli\n", "408 Roberto Piccoli Piccoli\n", "409 Charles Pickel Pickel\n", "410 Andrea Pinamonti Pinamonti\n", "411 Lorenzo Pirola Pirola\n", "412 Marko Pjaca Pjaca\n", "413 Tommaso Pobega Pobega\n", "414 Paul Pogba Pogba\n", "415 Matteo Politano Politano\n", "416 Marin Pongračić Pongracic\n", "417 Stefan Posch Posch\n", "418 Ivan Provedel Provedel\n", "419 Ignacio Pussetto Pussetto\n", "420 Niklas Pyyhtiä Pyyhtia\n", "421 Fabio Quagliarella Quagliarella\n", "422 Giacomo Quagliata Quagliata\n", "423 Adrien Rabiot Rabiot\n", "424 Nemanja Radonjić Radonjic\n", "425 Ivan Radovanović Radovanovic\n", "426 Ionuț Radu Radu\n", "427 Antonio Raimondo Raimondo\n", "428 Luca Ranieri Ranieri\n", "429 Andrea Ranocchia Ranocchia\n", "430 Filippo Ranocchia Ranocchia\n", "431 Giacomo Raspadori Raspadori\n", "432 Giacomo Raspadori Raspadori\n", "433 Nicola Ravaglia Ravaglia\n", "434 Ante Rebić Rebic\n", "435 Arkadiusz Reca Reca\n", "436 Panagiotis Retsos Retsos\n", "437 Franck Ribéry Ribery\n", "438 Samuele Ricci Ricci\n", "439 Tomás Rincón Rincon\n", "440 Pablo Rodríguez Rodriguez\n", "441 Ricardo Rodríguez Rodriguez\n", "442 Rogério Rogerio\n", "443 Alessio Romagnoli Romagnoli\n", "444 Simone Romagnoli Romagnoli\n", "445 Luka Romero Romero\n", "446 Marten de Roon Roon\n", "447 Nicolò Rovella Rovella\n", "448 Nicolò Rovella Rovella\n", "449 Amir Rrahmani Rrahmani\n", "450 Ruan Ruan\n", "451 Daniele Rugani Rugani\n", "452 Matteo Ruggeri Ruggeri\n", "453 Mário Rui Rui\n", "454 Abdelhamid Sabiri Sabiri\n", "455 Alexis Saelemaekers Saelemaekers\n", "456 Jacopo Sala Sala\n", "457 Lazar Samardzic Samardzic\n", "458 Junior Sambia Sambia\n", "459 Antonio Sanabria Sanabria\n", "460 Leandro Sanca Sanca\n", "461 Alex Sandro Sandro\n", "462 Nicola Sansone Sansone\n", "463 Riccardo Saponara Saponara\n", "464 Martin Satriano Satriano\n", "465 Giorgio Scalvini Scalvini\n", "466 Jerdy Schouten Schouten\n", "467 Perr Schuurs Schuurs\n", "468 Demba Seck Seck\n", "469 Jacopo Segre Segre\n", "470 Vivaldo Semedo Semedo\n", "471 Stefano Sensi Sensi\n", "472 Luigi Sepe Sepe\n", "473 Leonardo Sernicola Sernicola\n", "474 Stephan El Shaarawy Shaarawy\n", "475 Eldor Shomurodov Shomurodov\n", "476 Eldor Shomurodov Shomurodov\n", "477 Marco Silvestri Silvestri\n", "478 Giovanni Simeone Simeone\n", "479 Wilfried Singo Singo\n", "480 Salvatore Sirigu Sirigu\n", "481 Leo Skiri Østigård stigard\n", "482 Łukasz Skorupski Skorupski\n", "483 Milan Škriniar Skriniar\n", "484 Chris Smalling Smalling\n", "485 Ola Solbakken Solbakken\n", "486 Brandon Soppy Soppy\n", "487 Brandon Soppy Soppy\n", "488 Roberto Soriano Soriano\n", "489 Joaquin Sosa Sosa\n", "490 Riccardo Sottil Sottil\n", "491 Matìas Soulé Soule\n", "492 Adama Soumaoro Soumaoro\n", "493 Leonardo Spinazzola Spinazzola\n", "494 Marco Sportiello Sportiello\n", "495 Petar Stojanović Stojanovic\n", "496 Gabriel Strefezza Strefezza\n", "497 Dávid Strelec Strelec\n", "498 Isaac Success Success\n", "499 Ibrahim Sulemana Sulemana\n", "500 Wojciech Szczęsny Szczesny\n", "501 Benjamin Tahirovic Tahirovic\n", "502 Adrien Tameze Tameze\n", "503 Ciprian Tătărușanu Tatarusanu\n", "504 Filippo Terracciano Terracciano\n", "505 Pietro Terracciano Terracciano\n", "506 Aleksa Terzić Terzic\n", "507 Florian Thauvin Thauvin\n", "508 Malick Thiaw Thiaw\n", "509 Kristian Thorstvedt Thorstvedt\n", "510 Jeremy Toljan Toljan\n", "511 Rafael Tolói Toloi\n", "512 Fikayo Tomori Tomori\n", "513 Sandro Tonali Tonali\n", "514 Lorenzo Tonelli Tonelli\n", "515 William Troost-Ekong Troost-Ekong\n", "516 Frank Tsadjout Tsadjout\n", "517 Alessandro Tuia Tuia\n", "518 Martin Turk Turk\n", "519 Iyenoma Udogie Udogie\n", "520 Samuel Umtiti Umtiti\n", "521 Diego Valencia Valencia\n", "522 Emanuele Valeri Valeri\n", "523 Mattia Valoti Valoti\n", "524 Johan Vásquez Vasquez\n", "525 Matías Vecino Vecino\n", "526 Miguel Veloso Veloso\n", "527 Lorenzo Venuti Venuti\n", "528 Daniele Verde Verde\n", "529 Simone Verdi Verdi\n", "530 Valerio Verre Verre\n", "531 Guglielmo Vicario Vicario\n", "532 Ronaldo Vieira Vieira\n", "533 Ronaldo Vieira Vieira\n", "534 Emanuel Vignato Vignato\n", "535 Emanuel Vignato Vignato\n", "536 Samuele Vignato Vignato\n", "537 Tonny Vilhena Vilhena\n", "538 Gonzalo Villar Villar\n", "539 Matías Viña Vina\n", "540 Dušan Vlahović Vlahovic\n", "541 Nikola Vlašić Vlasic\n", "542 Joel Voelkerling Persson Persson\n", "543 Mërgim Vojvoda Vojvoda\n", "544 Cristian Volpato Volpato\n", "545 Lukáš Vorlický Vorlicky\n", "546 Aster Vranckx Vranckx\n", "547 Stefan de Vrij Vrij\n", "548 Walace Walace\n", "549 Sebastian Walukiewicz Walukiewicz\n", "550 Georginio Wijnaldum Wijnaldum\n", "551 Harry Winks Winks\n", "552 Przemysław Wiśniewski Wisniewski\n", "553 Gerard Yepes Yepes\n", "554 Mattia Zaccagni Zaccagni\n", "555 Denis Zakaria Zakaria\n", "556 Nicola Zalewski Zalewski\n", "557 Andre-Frank Zambo Anguissa Anguissa\n", "558 Luca Zanimacchia Zanimacchia\n", "559 Nicolò Zaniolo Zaniolo\n", "560 Alessandro Zanoli Zanoli\n", "561 Alessandro Zanoli Zanoli\n", "562 Mattia Zanotti Zanotti\n", "563 Duván Zapata Zapata\n", "564 Davide Zappacosta Zappacosta\n", "565 Karim Zedadka Zedadka\n", "566 Deyovaisio Zeefuik Zeefuik\n", "567 Marvin Zeegelaar Zeegelaar\n", "568 Alessio Zerbin Zerbin\n", "569 Piotr Zieliński Zielinski\n", "570 David Zima Zima\n", "571 Joshua Zirkzee Zirkzee\n", "572 Jeroen Zoet Zoet\n", "573 Nadir Zortea Zortea\n", "574 Nadir Zortea Zortea\n", "575 Petar Zovko Zovko\n", "576 Szymon Żurkowski Zurkowski\n", "577 Szymon Żurkowski Zurkowski\n", "578 Milan Đurić uric\n", "579 Filip Đuričić uricic\n", "580 Emil Audero Audero\n", "581 Francesco Bardi Bardi\n", "582 Marco Carnesecchi Carnesecchi\n", "583 Andrea Consigli Consigli\n", "584 Alessio Cragno Cragno\n", "585 Michele Di Gregorio Gregorio\n", "586 Bartłomiej Drągowski Dragowski\n", "587 Wladimiro Falcone Falcone\n", "588 Pierluigi Gollini Gollini\n", "589 Pierluigi Gollini Gollini\n", "590 Samir Handanović Handanovic\n", "591 Mike Maignan Maignan\n", "592 Federico Marchetti Marchetti\n", "593 Luís Maximiano Maximiano\n", "594 Alex Meret Meret\n", "595 Vanja Milinković-Savić Milinkovic-Savic\n", "596 Lorenzo Montipò Montipo\n", "597 Juan Musso Musso\n", "598 Guillermo Ochoa Ochoa\n", "599 André Onana Onana\n", "600 Rui Patrício Patricio\n", "601 Gianluca Pegolo Pegolo\n", "602 Simone Perilli Perilli\n", "603 Mattia Perin Perin\n", "604 Samuele Perisan Perisan\n", "605 Ivan Provedel Provedel\n", "606 Ionuț Radu Radu\n", "607 Nicola Ravaglia Ravaglia\n", "608 Luigi Sepe Sepe\n", "609 Marco Silvestri Silvestri\n", "610 Salvatore Sirigu Sirigu\n", "611 Łukasz Skorupski Skorupski\n", "612 Marco Sportiello Sportiello\n", "613 Wojciech Szczęsny Szczesny\n", "614 Ciprian Tătărușanu Tatarusanu\n", "615 Pietro Terracciano Terracciano\n", "616 Martin Turk Turk\n", "617 Guglielmo Vicario Vicario\n", "618 Jeroen Zoet Zoet\n", "619 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": 7, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
FROMTOTEAM
0stigardOstigardNapoli
1Min-jaeKimNapoli
2HjlundHojlundAtalanta
3GytkjrGytkjaerMonza
4CarlosAugustoMonza
5MhleMaehleAtalanta
6KjrKjaerMilan
7uricicDjuricicSampdoria
8uricDjuricHellas Verona
9ArthurCabralFiorentina
10MartinezAlvarezSassuolo
\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": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rcsv = pd.read_csv('config/name_fix.txt') \n", "name_fix = pd.DataFrame(rcsv)\n", "\n", "for i in range(name_fix.shape[0]):\n", " for j in range(players.shape[0]):\n", " if(players['surname'][j].lower() == name_fix['FROM'][i].lower() and players['team'][j].lower() == name_fix['TEAM'][i].lower()):\n", " players['surname'][j] = name_fix['TO'][i]\n", " print(name_fix['TO'][i])\n", "\n", "name_fix\n", "\n" ] }, { "cell_type": "markdown", "id": "3c686d9f", "metadata": {}, "source": [ "Load players from Fantacalcio list." ] }, { "cell_type": "code", "execution_count": 8, "id": "f96eaaa1", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_12904\\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_12904\\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_12904\\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_12904\\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idrnameteamsurnameinitial
0572PMeretNapoliMeret
12814PProvedelLazioProvedel
24964PVicarioEmpoliVicario
3453PSzczesnyJuventusSzczesny
42134PFalconeLecceFalcone
.....................
5385512ADe LucaSampdoriaLuca
5395837AVoelkerling PerssonLeccePersson
5406113AMontevagoSampdoriaMontevago
5416143AKrollisSpeziaKrollis
5426160AVivaldoUdineseVivaldo
\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": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fc_data = pd.read_excel('fantacalcio/Quotazioni_Fantacalcio.xlsx', 'Tutti', header = 1)\n", "\n", "fc_players = fc_data [['Id', 'R', 'Nome', 'Squadra']]\n", "\n", "fc_players = fc_players.rename(columns = {'Id' : 'id', 'R': 'r', 'Nome' : 'name', 'Squadra' : 'team'})\n", "\n", "fc_players['surname'] = fc_players['name']\n", "fc_players['initial'] = fc_players['name']\n", "\n", "\n", "for i in range(fc_players.shape[0]):\n", " spl = normalize_name( fc_players['name'][i].replace('\\'', '') ).split(' ')\n", " if('.' in spl[-1]):\n", " fc_players['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": 9, "id": "9c50e4b5", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_12904\\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_12904\\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": 10, "id": "18f6c5f2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Mirante not found\n", "Sarr M. not found\n", "Lamanna not found\n", "Ujkani not found\n", "Berisha not found\n", "Padelli not found\n", "Cordaz not found\n", "Pinsoglio not found\n", "Fiorillo not found\n", "Cerofolini not found\n", "Rossi F. not found\n", "Ravaglia F. from previous team stats\n", "Brancolini not found\n", "Bleve not found\n", "Berardi A. not found\n", "Russo A. not found\n", "Gemello 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", "Bereszynski from previous team stats\n", "Aiwu not found\n", "Radu from previous team stats\n", "Paletta not found\n", "Fares not found\n", "Romagna not found\n", "Amey not found\n", "Buta not found\n", "Guessand A. not found\n", "Guarino not found\n", "Machin not found\n", "Akpa Akpro not found\n", "Galdames not found\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_12904\\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": [ "Darboe not found\n", "Urbanski not found\n", "Bertini not found\n", "Trimboli not found\n", "Samek not found\n", "Degli Innocenti not found\n", "Faticanti not found\n", "Oddei not found\n", "Kaio Jorge 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": 11, "id": "3b4a36af", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idrnameteamsurnameinitialfb_ID
0572PMeretNapoliMeret594
12814PProvedelLazioProvedel605
24964PVicarioEmpoliVicario617
3453PSzczesnyJuventusSzczesny613
42134PFalconeLecceFalcone587
........................
5385512ADe LucaSampdoriaLuca145
5395837AVoelkerling PerssonLeccePersson542
5406113AMontevagoSampdoriaMontevago352
5416143AKrollisSpeziaKrollis277
5426160AVivaldoUdineseVivaldo-1
\n", "

543 rows × 7 columns

\n", "
" ], "text/plain": [ " id r name team surname initial fb_ID\n", "0 572 P Meret Napoli Meret 594\n", "1 2814 P Provedel Lazio Provedel 605\n", "2 4964 P Vicario Empoli Vicario 617\n", "3 453 P Szczesny Juventus Szczesny 613\n", "4 2134 P Falcone Lecce Falcone 587\n", ".. ... .. ... ... ... ... ...\n", "538 5512 A De Luca Sampdoria Luca 145\n", "539 5837 A Voelkerling Persson Lecce Persson 542\n", "540 6113 A Montevago Sampdoria Montevago 352\n", "541 6143 A Krollis Spezia Krollis 277\n", "542 6160 A Vivaldo Udinese Vivaldo -1\n", "\n", "[543 rows x 7 columns]" ] }, "execution_count": 11, "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": 12, "id": "1d73a312", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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": 13, "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": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "keeper_players.columns[4:]" ] }, { "cell_type": "code", "execution_count": 14, "id": "eb9127a9", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\nicol\\AppData\\Local\\Temp\\ipykernel_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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_12904\\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": 15, "id": "da977789", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idrnameteamsurnameinitialfb_IDagebirth_yeargames...gk_passes_length_avggk_goal_kicksgk_pct_goal_kicks_launchedgk_goal_kick_length_avggk_crossesgk_crosses_stoppedgk_crosses_stopped_pctgk_def_actions_outside_pen_areagk_def_actions_outside_pen_area_per90gk_avg_distance_def_actions
0572PMeretNapoliMeret59426-03419970...26.218520.026.8308103.2321.0717.0
12814PProvedelLazioProvedel60529-03919940...33.016136.034.7402174.2461.4916.4
24964PVicarioEmpoliVicario61726-20019960...33.313948.942.6489285.7150.6310.7
3453PSzczesnyJuventusSzczesny61333-00719900...34.311449.141.530193.0190.8915.4
42134PFalconeLecceFalcone58728-01319950...41.922577.352.4441225.0351.1313.7
..................................................................
5385512ADe LucaSampdoriaLuca14524-28219982...0.000.00.0000.000.000.0
5395837AVoelkerling PerssonLeccePersson54220-10020037...0.000.00.0000.000.000.0
5406113AMontevagoSampdoriaMontevago35220-03820036...0.000.00.0000.000.000.0
5416143AKrollisSpeziaKrollis27721-17920011...0.000.00.0000.000.000.0
5426160AVivaldoUdineseVivaldo-1000...0.000.00.0000.000.000.0
\n", "

543 rows × 158 columns

\n", "
" ], "text/plain": [ " id r name team surname initial fb_ID \\\n", "0 572 P Meret Napoli Meret 594 \n", "1 2814 P Provedel Lazio Provedel 605 \n", "2 4964 P Vicario Empoli Vicario 617 \n", "3 453 P Szczesny Juventus Szczesny 613 \n", "4 2134 P Falcone Lecce Falcone 587 \n", ".. ... .. ... ... ... ... ... \n", "538 5512 A De Luca Sampdoria Luca 145 \n", "539 5837 A Voelkerling Persson Lecce Persson 542 \n", "540 6113 A Montevago Sampdoria Montevago 352 \n", "541 6143 A Krollis Spezia Krollis 277 \n", "542 6160 A Vivaldo Udinese Vivaldo -1 \n", "\n", " age birth_year games ... gk_passes_length_avg gk_goal_kicks \\\n", "0 26-034 1997 0 ... 26.2 185 \n", "1 29-039 1994 0 ... 33.0 161 \n", "2 26-200 1996 0 ... 33.3 139 \n", "3 33-007 1990 0 ... 34.3 114 \n", "4 28-013 1995 0 ... 41.9 225 \n", ".. ... ... ... ... ... ... \n", "538 24-282 1998 2 ... 0.0 0 \n", "539 20-100 2003 7 ... 0.0 0 \n", "540 20-038 2003 6 ... 0.0 0 \n", "541 21-179 2001 1 ... 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.0 26.8 308 \n", "1 36.0 34.7 402 \n", "2 48.9 42.6 489 \n", "3 49.1 41.5 301 \n", "4 77.3 52.4 441 \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 10 3.2 \n", "1 17 4.2 \n", "2 28 5.7 \n", "3 9 3.0 \n", "4 22 5.0 \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 32 1.07 \n", "1 46 1.49 \n", "2 15 0.63 \n", "3 19 0.89 \n", "4 35 1.13 \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.0 \n", "1 16.4 \n", "2 10.7 \n", "3 15.4 \n", "4 13.7 \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 158 columns]" ] }, "execution_count": 15, "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": 16, "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": 17, "id": "61fac91a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "vote_avg 6.214595\n", "vote_std 0.457012\n", "dtype: float64\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
vote_avgvote_std
06.2000000.420317
16.2741940.418112
26.4583330.379601
36.0909090.324610
46.2258060.521145
56.2741940.418112
66.0000000.595683
76.1000000.300000
86.2941180.455645
96.0645160.396394
106.1363640.431220
116.2333330.359011
126.3636360.504115
136.3166670.524140
146.3000000.447214
156.2333330.460676
166.1833330.539804
176.0517240.546854
186.2500000.508850
196.0000000.451335
206.0000000.395285
216.0909090.467983
226.1666670.527046
236.4500000.522015
246.6071430.602927
256.2142860.364216
\n", "
" ], "text/plain": [ " vote_avg vote_std\n", "0 6.200000 0.420317\n", "1 6.274194 0.418112\n", "2 6.458333 0.379601\n", "3 6.090909 0.324610\n", "4 6.225806 0.521145\n", "5 6.274194 0.418112\n", "6 6.000000 0.595683\n", "7 6.100000 0.300000\n", "8 6.294118 0.455645\n", "9 6.064516 0.396394\n", "10 6.136364 0.431220\n", "11 6.233333 0.359011\n", "12 6.363636 0.504115\n", "13 6.316667 0.524140\n", "14 6.300000 0.447214\n", "15 6.233333 0.460676\n", "16 6.183333 0.539804\n", "17 6.051724 0.546854\n", "18 6.250000 0.508850\n", "19 6.000000 0.451335\n", "20 6.000000 0.395285\n", "21 6.090909 0.467983\n", "22 6.166667 0.527046\n", "23 6.450000 0.522015\n", "24 6.607143 0.602927\n", "25 6.214286 0.364216" ] }, "execution_count": 17, "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": 18, "id": "c9312080", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
vote_avgvote_std
06.2000000.420317
16.2741940.418112
26.4583330.379601
36.0909090.324610
46.2258060.521145
.........
5385.9585360.291436
5396.0681660.351902
5405.6184770.288497
5416.2903210.466766
5425.7906680.631282
\n", "

543 rows × 2 columns

\n", "
" ], "text/plain": [ " vote_avg vote_std\n", "0 6.200000 0.420317\n", "1 6.274194 0.418112\n", "2 6.458333 0.379601\n", "3 6.090909 0.324610\n", "4 6.225806 0.521145\n", ".. ... ...\n", "538 5.958536 0.291436\n", "539 6.068166 0.351902\n", "540 5.618477 0.288497\n", "541 6.290321 0.466766\n", "542 5.790668 0.631282\n", "\n", "[543 rows x 2 columns]" ] }, "execution_count": 18, "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": 19, "id": "b2570ce5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idrnameteamsurnameinitialfb_IDagebirth_yeargames...gk_pct_goal_kicks_launchedgk_goal_kick_length_avggk_crossesgk_crosses_stoppedgk_crosses_stopped_pctgk_def_actions_outside_pen_areagk_def_actions_outside_pen_area_per90gk_avg_distance_def_actionsvote_avgvote_std
0572PMeretNapoliMeret59426-03419970...20.026.8308103.2321.0717.06.2000000.420317
12814PProvedelLazioProvedel60529-03919940...36.034.7402174.2461.4916.46.2741940.418112
24964PVicarioEmpoliVicario61726-20019960...48.942.6489285.7150.6310.76.4583330.379601
3453PSzczesnyJuventusSzczesny61333-00719900...49.141.530193.0190.8915.46.0909090.324610
42134PFalconeLecceFalcone58728-01319950...77.352.4441225.0351.1313.76.2258060.521145
..................................................................
5385512ADe LucaSampdoriaLuca14524-28219982...0.00.0000.000.000.05.9585360.291436
5395837AVoelkerling PerssonLeccePersson54220-10020037...0.00.0000.000.000.06.0681660.351902
5406113AMontevagoSampdoriaMontevago35220-03820036...0.00.0000.000.000.05.6184770.288497
5416143AKrollisSpeziaKrollis27721-17920011...0.00.0000.000.000.06.2903210.466766
5426160AVivaldoUdineseVivaldo-1000...0.00.0000.000.000.05.7906680.631282
\n", "

543 rows × 160 columns

\n", "
" ], "text/plain": [ " id r name team surname initial fb_ID \\\n", "0 572 P Meret Napoli Meret 594 \n", "1 2814 P Provedel Lazio Provedel 605 \n", "2 4964 P Vicario Empoli Vicario 617 \n", "3 453 P Szczesny Juventus Szczesny 613 \n", "4 2134 P Falcone Lecce Falcone 587 \n", ".. ... .. ... ... ... ... ... \n", "538 5512 A De Luca Sampdoria Luca 145 \n", "539 5837 A Voelkerling Persson Lecce Persson 542 \n", "540 6113 A Montevago Sampdoria Montevago 352 \n", "541 6143 A Krollis Spezia Krollis 277 \n", "542 6160 A Vivaldo Udinese Vivaldo -1 \n", "\n", " age birth_year games ... gk_pct_goal_kicks_launched \\\n", "0 26-034 1997 0 ... 20.0 \n", "1 29-039 1994 0 ... 36.0 \n", "2 26-200 1996 0 ... 48.9 \n", "3 33-007 1990 0 ... 49.1 \n", "4 28-013 1995 0 ... 77.3 \n", ".. ... ... ... ... ... \n", "538 24-282 1998 2 ... 0.0 \n", "539 20-100 2003 7 ... 0.0 \n", "540 20-038 2003 6 ... 0.0 \n", "541 21-179 2001 1 ... 0.0 \n", "542 0 0 0 ... 0.0 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "0 26.8 308 10 \n", "1 34.7 402 17 \n", "2 42.6 489 28 \n", "3 41.5 301 9 \n", "4 52.4 441 22 \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 3.2 32 \n", "1 4.2 46 \n", "2 5.7 15 \n", "3 3.0 19 \n", "4 5.0 35 \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.07 17.0 \n", "1 1.49 16.4 \n", "2 0.63 10.7 \n", "3 0.89 15.4 \n", "4 1.13 13.7 \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.200000 0.420317 \n", "1 6.274194 0.418112 \n", "2 6.458333 0.379601 \n", "3 6.090909 0.324610 \n", "4 6.225806 0.521145 \n", ".. ... ... \n", "538 5.958536 0.291436 \n", "539 6.068166 0.351902 \n", "540 5.618477 0.288497 \n", "541 6.290321 0.466766 \n", "542 5.790668 0.631282 \n", "\n", "[543 rows x 160 columns]" ] }, "execution_count": 19, "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": 20, "id": "f7620abe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'gk_shots_on_target_against'" ] }, "execution_count": 20, "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": 21, "id": "700b7a7d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Zoet, 0.6666666666666667\n", "Pegolo, 0.33333333333333337\n", "Gollini, 0.16666666666666663\n", "Mirante, 0.0\n", "Sarr M., 0.0\n", "Lamanna, 0.0\n", "Ujkani, 0.0\n", "Berisha, 0.0\n", "Marchetti, 0.16666666666666663\n", "Perilli, 0.16666666666666663\n", "Padelli, 0.0\n", "Bardi, 0.16666666666666663\n", "Cordaz, 0.0\n", "Pinsoglio, 0.0\n", "Fiorillo, 0.0\n", "Cragno, 0.16666666666666663\n", "Sirigu, 0.16666666666666663\n", "Cerofolini, 0.0\n", "Rossi F., 0.0\n", "Ravaglia F., 0.6666666666666667\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.6666666666666667\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.33333333333333337\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": 22, "id": "2d9eee99", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idrnameteamsurnameinitialfb_IDagebirth_yeargames...gk_pct_goal_kicks_launchedgk_goal_kick_length_avggk_crossesgk_crosses_stoppedgk_crosses_stopped_pctgk_def_actions_outside_pen_areagk_def_actions_outside_pen_area_per90gk_avg_distance_def_actionsvote_avgvote_std
0572PMeretNapoliMeret59426-03419970...20.026.8308.010.03.232.01.0717.06.2000000.420317
12814PProvedelLazioProvedel60529-03919940...36.034.7402.017.04.246.01.4916.46.2741940.418112
24964PVicarioEmpoliVicario61726-20019960...48.942.6489.028.05.715.00.6310.76.4583330.379601
3453PSzczesnyJuventusSzczesny61333-00719900...49.141.5301.09.03.019.00.8915.46.0909090.324610
42134PFalconeLecceFalcone58728-01319950...77.352.4441.022.05.035.01.1313.76.2258060.521145
..................................................................
5385512ADe LucaSampdoriaLuca14524-28219982...0.00.00.00.00.00.00.000.05.9585360.291436
5395837AVoelkerling PerssonLeccePersson54220-10020037...0.00.00.00.00.00.00.000.06.0681660.351902
5406113AMontevagoSampdoriaMontevago35220-03820036...0.00.00.00.00.00.00.000.05.6184770.288497
5416143AKrollisSpeziaKrollis27721-17920011...0.00.00.00.00.00.00.000.06.2903210.466766
5426160AVivaldoUdineseVivaldo-1000...0.00.00.00.00.00.00.000.05.7906680.631282
\n", "

543 rows × 160 columns

\n", "
" ], "text/plain": [ " id r name team surname initial fb_ID \\\n", "0 572 P Meret Napoli Meret 594 \n", "1 2814 P Provedel Lazio Provedel 605 \n", "2 4964 P Vicario Empoli Vicario 617 \n", "3 453 P Szczesny Juventus Szczesny 613 \n", "4 2134 P Falcone Lecce Falcone 587 \n", ".. ... .. ... ... ... ... ... \n", "538 5512 A De Luca Sampdoria Luca 145 \n", "539 5837 A Voelkerling Persson Lecce Persson 542 \n", "540 6113 A Montevago Sampdoria Montevago 352 \n", "541 6143 A Krollis Spezia Krollis 277 \n", "542 6160 A Vivaldo Udinese Vivaldo -1 \n", "\n", " age birth_year games ... gk_pct_goal_kicks_launched \\\n", "0 26-034 1997 0 ... 20.0 \n", "1 29-039 1994 0 ... 36.0 \n", "2 26-200 1996 0 ... 48.9 \n", "3 33-007 1990 0 ... 49.1 \n", "4 28-013 1995 0 ... 77.3 \n", ".. ... ... ... ... ... \n", "538 24-282 1998 2 ... 0.0 \n", "539 20-100 2003 7 ... 0.0 \n", "540 20-038 2003 6 ... 0.0 \n", "541 21-179 2001 1 ... 0.0 \n", "542 0 0 0 ... 0.0 \n", "\n", " gk_goal_kick_length_avg gk_crosses gk_crosses_stopped \\\n", "0 26.8 308.0 10.0 \n", "1 34.7 402.0 17.0 \n", "2 42.6 489.0 28.0 \n", "3 41.5 301.0 9.0 \n", "4 52.4 441.0 22.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 3.2 32.0 \n", "1 4.2 46.0 \n", "2 5.7 15.0 \n", "3 3.0 19.0 \n", "4 5.0 35.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.07 17.0 \n", "1 1.49 16.4 \n", "2 0.63 10.7 \n", "3 0.89 15.4 \n", "4 1.13 13.7 \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.200000 0.420317 \n", "1 6.274194 0.418112 \n", "2 6.458333 0.379601 \n", "3 6.090909 0.324610 \n", "4 6.225806 0.521145 \n", ".. ... ... \n", "538 5.958536 0.291436 \n", "539 6.068166 0.351902 \n", "540 5.618477 0.288497 \n", "541 6.290321 0.466766 \n", "542 5.790668 0.631282 \n", "\n", "[543 rows x 160 columns]" ] }, "execution_count": 22, "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": 23, "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 }