SoccerViz


NameSoccerViz JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummaryA Package to allow analyzing soccer event data easily
upload_time2024-08-27 04:40:37
maintainerNone
docs_urlNone
authorAthal Akbar
requires_python<=3.12.1,>=3.8
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 


    pip install SoccerViz==0.6.0


Import the SoccerViz Package

    #SoccerViz Package
    from SoccerViz 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/1821060/Live/England-Premier-League-2024-2025-Aston-Villa-Arsenal'  #This is an example URL from Whoscored.com
    understat_url = 'https://understat.com/match/26618'  #Copy Link of the Understat URL


    #Call the extract functions to get Pass Dataframe,Players Dataframe of the particular match
    
    
    df = extract.pass_data(url)
    players_df = extract.player_data(url)
    home_df,away_df = extract.shots(understat_url)
    
    #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=24 #Arsenal Team ID
    away_team_id=13 #Aston Villa Team ID
    home_team_name = 'Arsenal'
    away_team_name = 'Aston Villa'


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)

    #Same goes for the shots of the match
    df1_missed,df2_missed,df1_saved,df2_saved,df1_goal,df2_goal,df1_block,df2_block,totalxG1,totalxG2=datafilter.analyze_shots(home_df,away_df)


Now finally, you can plot the pass network map for both the teams to analyze and visualize by calling the function
## Plotting Pass Network
    #Call the function and manually put in the home and away team names
    
    plot = plot.pass_network(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,home_team_name,away_team_name)
    
![passmap.png](SoccerViz%2Fpassmap.png)

## Plotting Prg Passes
    
    #Call the function and put in home and away team names
    plot = plot.prg_passes(df_comp_prg_home, df_uncomp_prg_home, df_comp_prg_away, df_uncomp_prg_away, home_team_name,
                    away_team_name)
![prgpassmap.png](SoccerViz%2Fprgpassmap.png)


## Plotting Shot Maps
    
    #Call the function 
    plot = plot.shot_map(df1_missed, df2_missed, df1_saved, df2_saved, df1_goal, df2_goal, df1_block, df2_block, home_team_name,
                 away_team_name,totalxG1, totalxG2)
    
![shotmap.png](SoccerViz%2Fshotmap.png)


## Compare Players from the Big 5 EU Leagues 2022-2024 seasons using Pizza Plots 

        First and foremost download the CSV File 'big5stats22-24.csv' *data from FBRef via WorldFootballR
        Or you can download from the GitHub>DATA
        #Load the CSV file as DF
        df = pd.read_csv('#filepath')

The available parameters are:
        ['Gls', 'Ast', 'G+A', 'xG', 'PrgC', 'PrgP', 'PrgR', 'Shots', 'Shts on Target', 
        'TklW', 'Blocks', 'Int', 'Succ Takeons', 'Recov', 'Aerial Duels', 'Pass CmpRate', 
        'LongPass CmpRate', 'KeyPasses', 'PassPA', 'FinalThird Passes', 'CrsPA']

Positions Values should be coherent with these:
        'DF', 'MF', 'FW', 'GK' 

Example Usage

        position = 'DF'  #specify the position
        player1 = 'Riccardo Calafiori'  # double-check spellings from FBRef
        player2 = 'Ben White'  # double-check special characters in player names
        
        #specify any parameters from the list above to compare players
        params = ['G+A', 'PrgC','PrgP', 'TklW','Blocks','Int','LongPass CmpRate','KeyPasses','CrsPA']

        values, values2 = datafilter.compare_players(df, position, player1, player2, params)
        plot = plot.pizza_plot(values, values2, params, player1, player2)
![calavzini_plot.png](SoccerViz%2Fcalavzini_plot.png)

## Plot ShotMaps for Individual Players throughout the Season

        playerid="5220" #put the player Id in strings from Understat.com URL
        season=2023 #season you wish to plot the shotmap of
        player_name = "Kai Havertz" #player_name
        
        plot = plot.playershots(playerid,season,player_name) #Call in the function to plot
        
![kai.png](SoccerViz%2Fkai.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": null,
    "name": "SoccerViz",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<=3.12.1,>=3.8",
    "maintainer_email": null,
    "keywords": "python, soccer, soccer analysis, passing network",
    "author": "Athal Akbar",
    "author_email": "athalkhan13@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/2b/cbefdfbcd000a09264db84fc255dcdaf5985bdbe4d96cb5b608612a6b752/SoccerViz-0.6.0.tar.gz",
    "platform": null,
    "description": "Installation\n\n## Use the package manager [pip](pypi.org) to install \n\n\n    pip install SoccerViz==0.6.0\n\n\nImport the SoccerViz Package\n\n    #SoccerViz Package\n    from SoccerViz 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/1821060/Live/England-Premier-League-2024-2025-Aston-Villa-Arsenal'  #This is an example URL from Whoscored.com\n    understat_url = 'https://understat.com/match/26618'  #Copy Link of the Understat URL\n\n\n    #Call the extract functions to get Pass Dataframe,Players Dataframe of the particular match\n    \n    \n    df = extract.pass_data(url)\n    players_df = extract.player_data(url)\n    home_df,away_df = extract.shots(understat_url)\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=24 #Arsenal Team ID\n    away_team_id=13 #Aston Villa Team ID\n    home_team_name = 'Arsenal'\n    away_team_name = 'Aston Villa'\n\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\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\n    #Same goes for the shots of the match\n    df1_missed,df2_missed,df1_saved,df2_saved,df1_goal,df2_goal,df1_block,df2_block,totalxG1,totalxG2=datafilter.analyze_shots(home_df,away_df)\n\n\nNow finally, you can plot the pass network map for both the teams to analyze and visualize by calling the function\n## Plotting Pass Network\n    #Call the function and manually put in the home and away team names\n    \n    plot = plot.pass_network(pass_between_home, pass_between_away, avg_loc_home,avg_loc_away,home_team_name,away_team_name)\n    \n![passmap.png](SoccerViz%2Fpassmap.png)\n\n## Plotting Prg Passes\n    \n    #Call the function and put in home and away team names\n    plot = plot.prg_passes(df_comp_prg_home, df_uncomp_prg_home, df_comp_prg_away, df_uncomp_prg_away, home_team_name,\n                    away_team_name)\n![prgpassmap.png](SoccerViz%2Fprgpassmap.png)\n\n\n## Plotting Shot Maps\n    \n    #Call the function \n    plot = plot.shot_map(df1_missed, df2_missed, df1_saved, df2_saved, df1_goal, df2_goal, df1_block, df2_block, home_team_name,\n                 away_team_name,totalxG1, totalxG2)\n    \n![shotmap.png](SoccerViz%2Fshotmap.png)\n\n\n## Compare Players from the Big 5 EU Leagues 2022-2024 seasons using Pizza Plots \n\n        First and foremost download the CSV File 'big5stats22-24.csv' *data from FBRef via WorldFootballR\n        Or you can download from the GitHub>DATA\n        #Load the CSV file as DF\n        df = pd.read_csv('#filepath')\n\nThe available parameters are:\n        ['Gls', 'Ast', 'G+A', 'xG', 'PrgC', 'PrgP', 'PrgR', 'Shots', 'Shts on Target', \n        'TklW', 'Blocks', 'Int', 'Succ Takeons', 'Recov', 'Aerial Duels', 'Pass CmpRate', \n        'LongPass CmpRate', 'KeyPasses', 'PassPA', 'FinalThird Passes', 'CrsPA']\n\nPositions Values should be coherent with these:\n        'DF', 'MF', 'FW', 'GK' \n\nExample Usage\n\n        position = 'DF'  #specify the position\n        player1 = 'Riccardo Calafiori'  # double-check spellings from FBRef\n        player2 = 'Ben White'  # double-check special characters in player names\n        \n        #specify any parameters from the list above to compare players\n        params = ['G+A', 'PrgC','PrgP', 'TklW','Blocks','Int','LongPass CmpRate','KeyPasses','CrsPA']\n\n        values, values2 = datafilter.compare_players(df, position, player1, player2, params)\n        plot = plot.pizza_plot(values, values2, params, player1, player2)\n![calavzini_plot.png](SoccerViz%2Fcalavzini_plot.png)\n\n## Plot ShotMaps for Individual Players throughout the Season\n\n        playerid=\"5220\" #put the player Id in strings from Understat.com URL\n        season=2023 #season you wish to plot the shotmap of\n        player_name = \"Kai Havertz\" #player_name\n        \n        plot = plot.playershots(playerid,season,player_name) #Call in the function to plot\n        \n![kai.png](SoccerViz%2Fkai.png)\n\n\n\n## Credits\n\nHuge 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    \nAnd 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.6.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        " soccer",
        " soccer analysis",
        " passing network"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0a988faaa7cd2b225fa3a7a605d295aee4804d560f0811e685efbf6537e8019",
                "md5": "ea826f4e1350b81ec8b405e1b7cb5d32",
                "sha256": "9ff901cec8b0e3385ea50b420164b14dc220bf2d63b579348cb3281fa46a8a51"
            },
            "downloads": -1,
            "filename": "SoccerViz-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ea826f4e1350b81ec8b405e1b7cb5d32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<=3.12.1,>=3.8",
            "size": 11516,
            "upload_time": "2024-08-27T04:40:35",
            "upload_time_iso_8601": "2024-08-27T04:40:35.062198Z",
            "url": "https://files.pythonhosted.org/packages/f0/a9/88faaa7cd2b225fa3a7a605d295aee4804d560f0811e685efbf6537e8019/SoccerViz-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd2bcbefdfbcd000a09264db84fc255dcdaf5985bdbe4d96cb5b608612a6b752",
                "md5": "3eac4d51ad95d8810d403590b04a26d3",
                "sha256": "3ccd2bf3d1b9759260fef1fb248ae384b53982c9fbed9744f5e7e5747ae14e06"
            },
            "downloads": -1,
            "filename": "SoccerViz-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3eac4d51ad95d8810d403590b04a26d3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<=3.12.1,>=3.8",
            "size": 12879,
            "upload_time": "2024-08-27T04:40:37",
            "upload_time_iso_8601": "2024-08-27T04:40:37.353682Z",
            "url": "https://files.pythonhosted.org/packages/dd/2b/cbefdfbcd000a09264db84fc255dcdaf5985bdbe4d96cb5b608612a6b752/SoccerViz-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-27 04:40:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "soccerviz"
}
        
Elapsed time: 0.29516s