{"id":898,"date":"2021-02-07T23:18:03","date_gmt":"2021-02-07T23:18:03","guid":{"rendered":"http:\/\/miguelpdl.com\/weblog\/?p=898"},"modified":"2021-02-07T23:18:03","modified_gmt":"2021-02-07T23:18:03","slug":"handling-statsbomb-event-data","status":"publish","type":"post","link":"https:\/\/miguelpdl.com\/weblog\/handling-statsbomb-event-data\/","title":{"rendered":"Handling StatsBomb Event Data"},"content":{"rendered":"\n<p>Yes I did have <a href=\"https:\/\/miguelpdl.com\/weblog\/?p=892\">a blog post back in September 2020<\/a>, highlighting that I was undertaking the&nbsp;<a href=\"https:\/\/uppsala.instructure.com\/courses\/28112\/assignments\/syllabus\">Uppsala University course \u201cMathematical Modelling of Football\u201d<\/a>&nbsp;which overtook my time and life in Q4 2020. In completing the course I&#8217;m finally getting my head up in 2021 to record all my notes and code and to take a journey to share those notes as I go down through each section and sub-section of the course.<\/p>\n\n\n\n<p>So here&#8217;s the first of hopefully many notes from the course, which were originally written in Asciidoc.<\/p>\n\n\n<div id=\"content\">\n<div id=\"preamble\">\n<div class=\"sectionbody\">\n<div class=\"paragraph\">&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_purpose\">Purpose of Handling Event Data<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The first element to work on via this course is <a href=\"https:\/\/uppsala.instructure.com\/courses\/28112\/pages\/1-visualising-actions\">Handling Event Data<\/a> and the purpose is to learn how to :-<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li>Download code and data<\/li>\n<li>Organise working folder<\/li>\n<li>Load in data from a json file.<\/li>\n<li>Using \u2018for\u2019 loops and \u2018if\u2019 statements<\/li>\n<li>Identify specific matches in Statsbomb data<\/li>\n<\/ul>\n<\/div>\n<div class=\"paragraph\">\n<p>The code needed for this lecture is available at the <a href=\"https:\/\/github.com\/Friends-of-Tracking-Data-FoTD\/SoccermaticsForPython\">Github SoccermaticsForPython<\/a> repo.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_set_up\">Set up<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Created a new organisation on <a href=\"https:\/\/github.com\/mmoffoot\">Github called mmoffoot<\/a> standing for Mathematical Modelling of Football. The purpose is to fork the Github projects used in the course to track my own changes to those repos.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>First up is a fork of the <a href=\"https:\/\/github.com\/mmoffoot\/SoccermaticsForPython\">SoccermaticsForPython repo into the mmoffoot<\/a> area.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Then created a branch called <a href=\"https:\/\/github.com\/mmoffoot\/SoccermaticsForPython\/tree\/week1\">&#8216;week1&#8217;<\/a> covering the changes I had made as of week1 of the course.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The next little hurdle here is the loading of the Statsbomb data. It\u2019s really in another repo on <a href=\"https:\/\/github.com\/statsbomb\/open-data\">Github called statsbomb \/ open-data <\/a> and in order to always have access to the StatsBomb data within this repo was going to set up a git submodule for this repo. This means that any time in the future when this repo is cloned (new) then it has to be done with the recursive command switch.<\/p>\n<\/div>\n<div class=\"quoteblock\">\n<blockquote>\n<div class=\"paragraph\">\n<p>git clone &#8211;recursive <a class=\"bare\" href=\"https:\/\/github.com\/mmoffoot\/SoccermaticsForPython\">https:\/\/github.com\/mmoffoot\/SoccermaticsForPython<\/a><\/p>\n<\/div>\n<\/blockquote>\n<\/div>\n<div class=\"paragraph\">\n<p>However then I noted that the StatsBomb data is over 3Gb in size and that it doesn\u2019t really make sense have a couple of copies of this data on the one machine so I just placed it in a directory higher.I then just add a soft link to the source data within the &#8216;Statsbomb&#8217; folder.<\/p>\n<\/div>\n<div class=\"quoteblock\">\n<blockquote>\n<div class=\"paragraph\">\n<p>ln -s ..\/..\/statsbomb-opendata\/data .<\/p>\n<\/div>\n<\/blockquote>\n<\/div>\n<div class=\"paragraph\">\n<p>Also modified the README file to point this out.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_what_was_coded\">What was coded<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The first exercise is to<\/p>\n<\/div>\n<div class=\"olist arabic\">\n<ol>\n<li>Edit the code to print out the result list for the Mens World cup<\/li>\n<li>Edit the code to find the ID for England vs. Sweden<\/li>\n<li>Write new code to write out a list of just Sweden\u2019s results in the tournament.<\/li>\n<\/ol>\n<\/div>\n<div class=\"paragraph\">\n<p>I made <a href=\"https:\/\/github.com\/mmoffoot\/SoccermaticsForPython\/blob\/week1\/1LoadInData.py\">the code changes to 1LoadInData.py<\/a> and run the code as<\/p>\n<\/div>\n<div class=\"quoteblock\">\n<blockquote>\n<div class=\"paragraph\">\n<p>python3 1LoadInData.py<\/p>\n<\/div>\n<\/blockquote>\n<\/div>\n<div class=\"paragraph\">\n<p>The output reads<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code>The match between Croatia and Denmark finished 1 : 1\nThe match between Australia and Peru finished 0 : 2\n.........\n.........\nThe match between Spain and Russia finished 1 : 1\nThe match between Croatia and England finished 2 : 1\nThe Sweden match between Mexico and Sweden finished 0 : 3\nThe Sweden match between Sweden and South Korea finished 1 : 0\nThe Sweden match between Sweden and Switzerland finished 1 : 0\nSweden vs England has id:8651\nThe Sweden match between Sweden and England finished 0 : 2\nThe Sweden match between Germany and Sweden finished 2 : 1<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>I think the exercise is complete.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_what_was_learned\">What was learned<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Learning how to extract match results from the StatsBomb open data is important, and being able to read in the <a href=\"https:\/\/github.com\/statsbomb\/open-data\">StatsBomb open data<\/a> is great because at the time of writing it has a number of competitions covered in it.<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li>International Mens FIFA World Cup 2018 (competition_id=43)<\/li>\n<li>Europe Champions League 2018\/2019<\/li>\n<li>Europe Champions League 2017\/2018<\/li>\n<li>Europe Champions League 2016\/2017<\/li>\n<li>Europe Champions League 2015\/2016<\/li>\n<li>Europe Champions League 2014\/2015<\/li>\n<li>Europe Champions League 2013\/2014<\/li>\n<li>Europe Champions League 2012\/2013<\/li>\n<li>Europe Champions League 2011\/2012<\/li>\n<li>Europe Champions League 2010\/2011<\/li>\n<li>Europe Champions League 2009\/2010<\/li>\n<li>Europe Champions League 2008\/2009<\/li>\n<li>Europe Champions League 2006\/2007<\/li>\n<li>Europe Champions League 2004\/2005<\/li>\n<li>Europe Champions League 2003\/2004<\/li>\n<li>Europe Champions League 1999\/2000<\/li>\n<li>Spain La Liga 2018\/2019<\/li>\n<li>Spain La Liga 2017\/2018<\/li>\n<li>Spain La Liga 2016\/2017<\/li>\n<li>Spain La Liga 2015\/2016<\/li>\n<li>Spain La Liga 2014\/2015<\/li>\n<li>Spain La Liga 2013\/2014<\/li>\n<li>Spain La Liga 2012\/2013<\/li>\n<li>Spain La Liga 2011\/2012<\/li>\n<li>Spain La Liga 2010\/2011<\/li>\n<li>Spain La Liga 2009\/2010<\/li>\n<li>Spain La Liga 2008\/2009<\/li>\n<li>Spain La Liga 2007\/2008<\/li>\n<li>Spain La Liga 2006\/2007<\/li>\n<li>Spain La Liga 2005\/2006<\/li>\n<li>Spain La Liga 2004\/2005<\/li>\n<li>England Premier League 2003\/2004<\/li>\n<li>International Women\u2019s World Cup 2019 (competition_id=72)<\/li>\n<li>United States of America NWSL (Female) 2018<\/li>\n<li>England FA Women\u2019s Super League 2019\/2020<\/li>\n<li>England FA Women\u2019s Super League 2018\/2019<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Yes I did have a blog post back in September 2020, highlighting that I was undertaking the&nbsp;Uppsala University course \u201cMathematical Modelling of Football\u201d&nbsp;which overtook my time and life in Q4 2020. In completing the course I&#8217;m finally getting my head up in 2021 to record all my notes and code and to take a journey [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[199],"tags":[185,204,202],"class_list":["post-898","post","type-post","status-publish","format-standard","hentry","category-mathematical-modelling-of-football","tag-football","tag-friends-of-tracking","tag-mathematical"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7O9Cj-eu","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts\/898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/comments?post=898"}],"version-history":[{"count":4,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts\/898\/revisions"}],"predecessor-version":[{"id":902,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts\/898\/revisions\/902"}],"wp:attachment":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/media?parent=898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/categories?post=898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/tags?post=898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}