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.
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)
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()
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
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
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?
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
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'
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()
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
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
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)
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.
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?
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
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
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.
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 ?
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.
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)
Many thanks very true
Can you pls explain me the use of dx-x and dy-y and similarly pitchlength-x and pitchwidth-y ?
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()
Really appreciate what you've done in the video and very much love your accent!
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?
when i open the link to github page browser show me 'Page not found', could you reload the files please? Thank you very much
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/
Thank you so much, that's what i need .
The github link isn't working. Think this is the one that should be there though... github.com/Friends-of-Tracking-Data-FoTD/SoccermaticsForPython
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.
mate i have an error that says 'no module named FCPython' do you know how to fix it?
@@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
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
I am afraid the github link is dead :/ Can anyone repair it?
if i want to get all Harry Kane shots on the world cup, what do i need to do? i didnt finde the way to get all matchs data.
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?
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
Anyone else getting this error: NameError: name 'pitchLengthX' is not defined
? Not able to plot the pitch after importing FCPython
The git hub page seems to be out, any other way one can get this code? Thanks
great stuff
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'
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()
Why -dy in Arrow() again, you've already did that in the previous line , I used dy-y only once and it worked fine for me, maybe try that !
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
For the shot maps, is it possible to get the player’s nickname displayed for the goals instead of their full names?
try using .split()
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
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)
he used a library
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.
Did you get the answer?
Hi, I could not access to the discord channel. Can anyone invite me to the group? I would really appreciate it.
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?
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.
Thanks for the video. Really helpful for me ,
and i try hard to show both off pass and shot in plt . to can see both in displayed ... any hellp thnx
So If I wanted to plot one players shots over the course of multiple games, what’s the best way to go about doing it ?
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
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
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.
My advice would be try use 'print' in every statement.If you don't understand some code 'print out' and I think it will help.
@@hrantbaloyan4652 Thanks, mate. I'll try :)
Can someone send to me the discord invite again? The invite in the video is expirated. Thanks!
Wouldn't be easier to use json_normalize? It looks way tidier
I have this error that reads 'No module named FCPython' does anyone know how to fix this?
You need to have the file under the same folder of the project look under description to download the code from GitHub
@@aliwualk thanks! Any idea why some passes seem to be going out of the pitch?
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
@@aliwualk alright thanks mate!
Hi i cant do the exercise for pass
I wrote code by myself and it didn't work
Can you send the pass code for me?
i can send it to you, if you want. However, I have a different code style...
@@Jimmypenguinboy could you please send me via email? muhfsl@gmail.com
Thank you ,
@@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
here you have: vascomano.github.io/Futebol/jupyter/2020/04/11/FoTlesson2.html
@@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 ?
Is anyone else facing issues in converting json file to a pandas dataframe? If yes and you resolved it, Please help me. Thank you!
use pd.json_normalize(), the code shown in the video has been deprecated when a new pandas was released
this is a bit annoying. i cannot open the links they upload
interesting
Hello fellow learners, Can someone send to me the discord invite again?
Hi, can somebody generate a new discord invitation link? Thanks!