Thank you for your contributes Sir.You got me dreaming by this course.I couldn't be a footballer but I believe I may catch my passion by helping footballer on the pitch.Hope to meet you.Greetings from Turkey.
Thank you Mr Sumper, I am learning a lot and is enjoyable too. I hope you don't mind I leave the code from the passes exercise Regards. # draw passes for label, thepass in passes.iterrows(): if thepass['player_name'] == 'Sara Caroline Seger': x = thepass['location'][0] y = thepass['location'][1] passCircle=plt.Circle((x, pitchWidthY-y),2, color="blue") passCircle.set_alpha(.2) ax.add_patch(passCircle) dx = thepass['pass_end_location'][0]-x dy = thepass['pass_end_location'][1]-y passArrow = plt.Arrow(x, pitchWidthY-y, dx, dy, width=3, color='blue') ax.add_patch(passArrow) fig.set_size_inches(10, 7) fig.savefig('passes.pdf', dpi=100) plt.show()
Thanks for the video. Really helpful ! One correction though - It should be " - dy" instead of "dy" in the command >>> passArrow = plt.Arrow(x, pitchWidthY- y, dx, -dy)
I tried to plot the shot map with (x, y) in dataset. It seem like both team attack from left to right. I also tried to do the same thing with (pitchLengthX-x, pitchLengthY-y) for Sweden shot map which switches Sweden attack from right to left. In both case, Eva Sofia Jakobsson goal is on the right-hand side of offensive side. However, the goal is on the left-hand side of offensive side in the sample code. Could anyone help me sort it out? Did I do anything wrong?
Can anyone explain me why the "pitchlengthX-x" and "pitchwidthy-y" when and where to use it ? Why not plot the same ? Is it so that we include the 1st and 2nd halves played by the team when we do that ?
You don't necessarily have to do that. I believe he did this to leave the pitch at the same orientation of the TV camera, you can check that by watching the videos of that particular match. Also, the positions of both teams come as if they were attacking to the same side.
I don't know if you are still having issues understanding this, but, in contrast with what Ciro said, I don't think it is optional. If you don't do it it won't reflect the correct place of events, imo. It happens because there is a difference between matplotlib's coordinate system and Statsbomb's one. I wrote a blog post about the exercise in this class where I mention this if you are still interested: dunderdanilo.com/plotting-passes/
Sorry but I've got a problem impossible to draw the pitch however I open FCPython modul. I draw a pitch but from the FC Python site directly and it works. And after it's impossible to plot the passes but I suppose it's link to the pitch not from the FCPython modul.
@@sethlxk you should have the working directory in the path of your FCPython.py file check in the upper part of spyder if you are positioned in the folder of SoccermaticsForPython downloaded from github
Hi everyone, this is an excellent resource and has got me really into data and analytics. Has been very challenging with no previous background in python or maths/ physics. I'm looking to try and create a pass map of passes played from a specific position on the pitch, can anyone help with this or provide me with some code to look at? I've managed to plot individual player and shot maps using the stats bomb data set. Thanks in advance
at around 4:00, David mentions that the positions of player' not-on-the-ball wouldn't be tracked. Does anybody know of any decent material describing how this can be achieved? It's multi-object tracking, sure. But How to map those objects onto a pitch, using say- two camera angles? Thanks
Anyone else had this problem? I get "MemoryError: In RendererAgg: Out of memory" when I try to draw the initial shot map and I can't figure out how to fix it.
Good afternoon, David. First of all, THANKS A LOT for what you're doing during these hard times for those who are learning Data Analytics. In my case, I'm getting a Master Degree in Big Data in Sports, but I wanted to learn by myself some Python tools. My problem is that I'm not able to watch the full code you're displaying, which made me unable to display any of these maps and get a full insight of it. Would you please help me? Thanks a lot again.
I couldn't plot the passes. What I'm doing wrong? #Plot the passes from FCPython import createPitch (fig,ax) = createPitch(pitchLengthX,pitchWidthY,'yards','gray') for i,thepass in passes.iterrows(): if thepass ['player_name']=='Sara Caroline Seger': x=thepass['location'][0] y=thepass['location'][1] passCircle=plt.Circle((x,PitchWidthY-y),2,color="blue") passCircle.set_alpha(.2) ax.add_patch(passCircle) dx=thepass['pass_end_location'][0]-x dy=thepass['pass_end_location'][1]-y passArrow=plt.Arrow(x,PitchWidthY-y,dx,-dy,width=3,color="blue") fig-set_size_inches(10,7) fig.savefig('Output/passes.pdf',dpi=100) plt-show()
if it's a whole string like "firstname lastname" you can use name_variable.split(" ") , or otherwise if it's custom nicknames that aren't in the dataset, i.e. south american nicknames then you can make a map with the original names as keys and the nicknames as values so you would go: nickname=map_name["original name"] to give you the nickname
Hello, I'm getting an error with line 30, TypeError: json_normalize() got an unexpected keyword argument 'sep'. Has anyone else had this issue? If so, can you provide a solution. No luck searching google. Thanks
Hello, when I try to load in the data, it says the file or directory does not exist. However I went to the source in the comment of the code and found the file and viewing the raw code shows me it is the same data as used before with the correct ID. I know this is a few months later so something could be outdated, but any chance for some help with this?
is that an error? runcell(0, 'C:/Users/zanay/Documents/Base de datos friends of tracking/SoccermaticsForPython-master/2PlotShotsAndPasses.py') Traceback (most recent call last): File "C:\Users\zanay\Documents\Base de datos friends of tracking\SoccermaticsForPython-master\2PlotShotsAndPasses.py", line 23, in with open('Statsbomb/data/events/'+file_name) as data_file: FileNotFoundError: [Errno 2] No such file or directory: 'Statsbomb/data/events/69301.json'
Hi, I have a problem installing FCPython module in Anaconda. I was typing "conda install FCPython" in my terminal but it returns an error code "zsh: command not found: conda". Did I not have my Anaconda properly installed?
I'm guessing you already figured this out but in case you haven't: 1. FCPython is not a module but a file. In Python importing files and modules has shares the "import" syntax. If you cloned his github repo you should have a file in there called FCPython.py 2. It does look like conda isn't working, maybe you haven't added it to path? stackoverflow.com/questions/31615322/zsh-conda-pip-installs-command-not-found
So, I started working on it and found out how to do that ! I've written the code for separating a team's shots alone, but you can easily modify it for any particular player ! I'll attach my github link for that ! github.com/guna1199/mi_scripts/blob/chunks/shots_alone_df.py
How did you bring the pitch in - that step was skipped completely..? I know the code is there yet how do you import it. I'm trying a work around of writing the code and plotting the for loop just before the chart output (plt.show)
I'm having a problem when I try and experiment with different competitions and league, when I plot a player's passes most passes seem to be passed to the outside of the pitch. Found this using La Liga competition files and Women's League files. Any help?
seth lee , No problem, my map show the all passes inside the map, just review the code, is probably a typo. in another comment I have paste my code for the exercise, have a look, Thanks
@@sethlxk look comment: Christoph D.1 week ago If you try to plot an arrow you have to look at your parameters. They are starting location and dx,dy! Not the end location coordinates. REPLY
@@muhammadfaisal6052 yes, I work with jupyter notebook (instead of spyder) and with lists (instead of multiple ifs). Is that ok? The result is the same
@@Jimmypenguinboy Can you explain me why the "pitchlengthX-x" and "pitchwidthy-y" when and where to use it ? Why not plot the same ? Are we considering the 1st and 2nd halves played by the team when we do that ?