Installation
Use the package manager [pip](pypi.org) to install mplsoccer
pip install SoccerWizz 0.0.1
Import the necessary Libraries and SoccerViz Package
import re
import json
import pandas as pd
import requests
from bs4 import BeautifulSoup
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import to_rgba
import matplotlib.patheffects as path_effects
from mplsoccer import VerticalPitch, Pitch, FontManager
from highlight_text import ax_text
#SoccerViz Package
from SoccerWizz import plot,extract,datafilter
Scrape event data from **[WhoScored](whoscored.com)** **_ONLY_** inorder to use it for data analysis and visualization, you would have to fill in the following parameters according to
your liking, below example is given follow it and keep in mind the instructions given too with the code.
#This is an example URL from Whoscored.com similar to the below one
url = 'https://www.whoscored.com/Matches/1729448/Live/England-Premier-League-2023-2024-Manchester-United-Tottenham' #This is an example URL from Whoscored.com
#Put your USER AGENT in the HEADERS parameter, you can find yours on "https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending"
HEADERS = {
""
}
#Call the extract functions to get Pass Dataframe and Players Dataframe of the particular match
df = extract.pass_data(url,HEADERS)
players_df = extract.player_data(url,HEADERS)
#You can find the TEAM Id's of the clubs on their WhoScored page html tags by clicking on the club logos
home_team_id=30 #Man Utd Team ID
away_team_id=32 #Spurs Team ID
After scrapping the event data and assembling into DataFrames, you will need to filter the data according to the teams and players.
#Filter all the data according to the teams by calling the function into DataFrames(their names are pretty self explanatory)
#You can use and call any dataframe you would like to analyze in raw tables and columns i.e. in a DataFrame form
pass_between_home, pass_between_away, avg_loc_home, avg_loc_away, passes_home, passes_away,df_prg_home,df_comp_prg_home,df_uncomp_prg_home,df_prg_away,df_comp_prg_away,df_uncomp_prg_away = datafilter.analyze_passes(df, players_df, home_team_id, away_team_id)
Now finally, you can plot the pass network map for both the teams to analyze and visualize by calling the function
#Call the function and manually put in the home and away team names
hometeam_name = 'Man Utd'
awayteam_name = 'Spurs'
plot = plot.pass_network(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,hometeam_name,awayteam_name)
![test1.png](SoccerWizz%2Ftest1.png)
Credits
Huge Shoutout to the guys at Mplsoccer, do check their package out also, and also checkout Mckay Johns Youtube Channel, which helped me alot in learning python and football analytics
And please don't forget to drop me feedback on Twitter/X, @athalakbar13.
Enjoy!!
Raw data
{
"_id": null,
"home_page": "",
"name": "SoccerWizz",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<=3.12.1",
"maintainer_email": "",
"keywords": "python,soccer,soccer analysis,passing network",
"author": "Athal Akbar",
"author_email": "athalkhan13@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d2/21/0de2784a5365546282fbe04ff368233f81ea995210022fb79a3058284203/SoccerWizz-0.0.2.tar.gz",
"platform": null,
"description": "Installation\n\nUse the package manager [pip](pypi.org) to install mplsoccer\n \n pip install SoccerWizz 0.0.1\n\nImport the necessary Libraries and SoccerViz Package\n \n import re\n import json\n import pandas as pd\n import requests\n from bs4 import BeautifulSoup\n import numpy as np\n import matplotlib.pyplot as plt\n from matplotlib.colors import to_rgba\n import matplotlib.patheffects as path_effects\n from mplsoccer import VerticalPitch, Pitch, FontManager\n from highlight_text import ax_text\n \n #SoccerViz Package\n from SoccerWizz import plot,extract,datafilter\n\nScrape event data from **[WhoScored](whoscored.com)** **_ONLY_** inorder to use it for data analysis and visualization, you would have to fill in the following parameters according to\nyour liking, below example is given follow it and keep in mind the instructions given too with the code.\n \n \n #This is an example URL from Whoscored.com similar to the below one\n \n url = 'https://www.whoscored.com/Matches/1729448/Live/England-Premier-League-2023-2024-Manchester-United-Tottenham' #This is an example URL from Whoscored.com\n \n #Put your USER AGENT in the HEADERS parameter, you can find yours on \"https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending\"\n \n HEADERS = {\n \"\"\n }\n\n #Call the extract functions to get Pass Dataframe and Players Dataframe of the particular match\n \n df = extract.pass_data(url,HEADERS)\n players_df = extract.player_data(url,HEADERS)\n \n #You can find the TEAM Id's of the clubs on their WhoScored page html tags by clicking on the club logos\n \n home_team_id=30 #Man Utd Team ID\n away_team_id=32 #Spurs Team ID\n\nAfter scrapping the event data and assembling into DataFrames, you will need to filter the data according to the teams and players.\n\n #Filter all the data according to the teams by calling the function into DataFrames(their names are pretty self explanatory)\n #You can use and call any dataframe you would like to analyze in raw tables and columns i.e. in a DataFrame form\n pass_between_home, pass_between_away, avg_loc_home, avg_loc_away, passes_home, passes_away,df_prg_home,df_comp_prg_home,df_uncomp_prg_home,df_prg_away,df_comp_prg_away,df_uncomp_prg_away = datafilter.analyze_passes(df, players_df, home_team_id, away_team_id)\n\nNow finally, you can plot the pass network map for both the teams to analyze and visualize by calling the function\n\n #Call the function and manually put in the home and away team names\n hometeam_name = 'Man Utd'\n awayteam_name = 'Spurs'\n plot = plot.pass_network(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,hometeam_name,awayteam_name)\n \n![test1.png](SoccerWizz%2Ftest1.png)\n\n\nCredits\n \n Huge Shoutout to the guys at Mplsoccer, do check their package out also, and also checkout Mckay Johns Youtube Channel, which helped me alot in learning python and football analytics\n \n And please don't forget to drop me feedback on Twitter/X, @athalakbar13.\n\nEnjoy!!\n\n \n",
"bugtrack_url": null,
"license": "Unlicensed",
"summary": "A Package to allow analyzing soccer event data easily",
"version": "0.0.2",
"project_urls": null,
"split_keywords": [
"python",
"soccer",
"soccer analysis",
"passing network"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a26b90a6a9d0afde7acac8c818d22bca4600b227905521df821efba19d3c6290",
"md5": "718e39d400e8b0b060b2768a8e2bf99b",
"sha256": "b07f73d85a0e883c74a866bec138a7c876139d7d662ceba194cf2773b8476c5f"
},
"downloads": -1,
"filename": "SoccerWizz-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "718e39d400e8b0b060b2768a8e2bf99b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<=3.12.1",
"size": 6715,
"upload_time": "2024-01-24T12:38:55",
"upload_time_iso_8601": "2024-01-24T12:38:55.863639Z",
"url": "https://files.pythonhosted.org/packages/a2/6b/90a6a9d0afde7acac8c818d22bca4600b227905521df821efba19d3c6290/SoccerWizz-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d2210de2784a5365546282fbe04ff368233f81ea995210022fb79a3058284203",
"md5": "bc481f50eb3729eed958a27014a736a2",
"sha256": "4be3cafe54652aaeb85db4c522ad10faecdacca5cceb2eb18705965d1b4aba32"
},
"downloads": -1,
"filename": "SoccerWizz-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "bc481f50eb3729eed958a27014a736a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<=3.12.1",
"size": 6309,
"upload_time": "2024-01-24T12:38:57",
"upload_time_iso_8601": "2024-01-24T12:38:57.315258Z",
"url": "https://files.pythonhosted.org/packages/d2/21/0de2784a5365546282fbe04ff368233f81ea995210022fb79a3058284203/SoccerWizz-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-24 12:38:57",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "soccerwizz"
}