Soccerytics


NameSoccerytics JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryA Package to allow analyzing soccer event data easily
upload_time2024-01-24 12:03:42
maintainer
docs_urlNone
authorAthal Akbar
requires_python>=3.8,<=3.12.1
licenseUnlicensed
keywords python soccer soccer analysis passing network
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Installation

Use the package manager [pip](pypi.org) to install mplsoccer
        
        pip install Soccerytics 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 Soccerytics 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
    home_team_name = 'Man Utd'
    away_team_name = 'Spurs'
    plot = plot.pass_network(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,hometeam_name,awayteam_name)
    
![test1.png](SoccerViz%2Ftest1.png)

You can also plot Progressive Passes for the match
   
    #Again Call the function and manually put in the home and away team names
    home_team_name = 'Man Utd'
    away_team_name = 'Spurs'
    plot = plot.prg_passes(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,hometeam_name,away_name)
![test.png](SoccerViz%2Ftest.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": "Soccerytics",
    "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/6e/32/4eec23919e28132f8a173f5303a55cf509fd6b66a3fc850887d407ed835f/Soccerytics-0.0.1.tar.gz",
    "platform": null,
    "description": "Installation\n\nUse the package manager [pip](pypi.org) to install mplsoccer\n        \n        pip install Soccerytics 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 Soccerytics 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    home_team_name = 'Man Utd'\n    away_team_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](SoccerViz%2Ftest1.png)\n\nYou can also plot Progressive Passes for the match\n   \n    #Again Call the function and manually put in the home and away team names\n    home_team_name = 'Man Utd'\n    away_team_name = 'Spurs'\n    plot = plot.prg_passes(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,hometeam_name,away_name)\n![test.png](SoccerViz%2Ftest.png)\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.1",
    "project_urls": null,
    "split_keywords": [
        "python",
        "soccer",
        "soccer analysis",
        "passing network"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d6135fd975e5560b036c45e9dbd21d197b0d7cd1f29e9d627d985b3b253a63e",
                "md5": "4db83f7f2a092578e9f21e70470adfc0",
                "sha256": "a9fdbd506a3111e9d5e1f647d081836d0127b068a7aed911f7af880e0a69fc0d"
            },
            "downloads": -1,
            "filename": "Soccerytics-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4db83f7f2a092578e9f21e70470adfc0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<=3.12.1",
            "size": 7198,
            "upload_time": "2024-01-24T12:03:39",
            "upload_time_iso_8601": "2024-01-24T12:03:39.336372Z",
            "url": "https://files.pythonhosted.org/packages/2d/61/35fd975e5560b036c45e9dbd21d197b0d7cd1f29e9d627d985b3b253a63e/Soccerytics-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e324eec23919e28132f8a173f5303a55cf509fd6b66a3fc850887d407ed835f",
                "md5": "df55557d13125db01cb695fb75328c23",
                "sha256": "97a2518d2b658819d1576df45ecf5030a14d752fe80b39dcb1fe2149d678f1ff"
            },
            "downloads": -1,
            "filename": "Soccerytics-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "df55557d13125db01cb695fb75328c23",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<=3.12.1",
            "size": 7876,
            "upload_time": "2024-01-24T12:03:42",
            "upload_time_iso_8601": "2024-01-24T12:03:42.521577Z",
            "url": "https://files.pythonhosted.org/packages/6e/32/4eec23919e28132f8a173f5303a55cf509fd6b66a3fc850887d407ed835f/Soccerytics-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-24 12:03:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "soccerytics"
}
        
Elapsed time: 0.19187s