{ "info": { "author": "Alfredo Medina", "author_email": "alfremedpal@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# PandasBasketball\nPandasBasketball is a small module intended to scrape data from [basketball-reference](https://www.basketball-reference.com/) and convert it to useful pandas data structures, such as data frames, for future analytical purposes. The use of jupyter notebooks is encouraged.\n\n# Installation\n```\npip install PandasBasketball\n```\n\nAfter installation you can then import it to your environment like this:\n```\nfrom PandasBasketball import pandasbasketball as pb\n```\n\n## Requirements\nPlease make sure you meet the following rquirements:\n- Python 3.6+\n- requests\n- pandas\n- Beautiful Soup 4\n\nAll the requirements can easily be met with the installation of the [Anaconda](https://www.anaconda.com/download/) distribution.\n\n# Usage\n## :basketball: Players\nInside a player's page on the basketball-reference website you can find several tables, and most of these tables can be obtained as a pandas data frame by calling `get_player(player, stat)`. The 'player' refers to the name of the html file used by basketball-reference inside the url, and the 'stat' means the type of table.\n\nThe currently supported tables are:\n- Per Game (`per_game`)\n- Totals (`totals`)\n- Per 36 Minutes (`per_minute`)\n- Per 100 Poss (`per_poss`)\n- Advanced (`advanced`)\n- Playoffs Per Game (`playoffs_per_game`)\n- Playoffs Totals (`playoffs_totals`)\n- Playoffs Per 36 Minutes (`playoffs_per_minute`)\n- Playoffs Per 100 Poss (`playoffs_per_poss`)\n- Playoffs Advanced (`playoffs_advanced`)\n\nThe rest of the tables will come in the future.\n\n### Example\nTo get the 'Per Game' table for LeBron James you would do something like this:\n```\ndf = pb.get_player(\"jamesle01\", \"per_game\")\n```\n\n### Optional Arguments\nThe `get_player()` method supports two optional arguments:\n- `numeric` - returns the data frame with its columns alreay converted to numeric\n- `s_index` - returns the data frame with its column 'Season' as the index\n\nBoth are set to `False` by deault.\n\n### Considerations\n- The resulting data frame **does not** include the table's footer.\n- The resulting data frame will have the same column names as the table's header but it will not have a set index. To set the 'Season' column as index set the argument `s_index` to `True`. \n- The columns will be of type 'object', so in order to perform arithmetic functions on them you will need to convert them to numeric. You can do something like this:\n```\nlbj_pg = pb.get_player(\"jamesle01\", \"per_game\")\nlbj_pg[lbj_pg.columns] = lbj_pg[lbj_pg.columns].apply(pd.to_numeric, errors=\"ignore\")\n```\nOr you cant set the optional argument `numeric` to `True`.\n\n## :basketball: Player Game Logs\nYou can get all of a player's games in a season by calling `get_player_gamelog(player, season)`. The `season` argument must be the last year in which the season took place. \n\n### Example\nTo get all of Kawhi Leonard's games during the 2017-2018 season:\n```\ndf = pb.get_player_gamelog(\"leonaka01\", \"2018\")\n```\n\n### Optional Arguments\nThe function `get_player_gamelog` supports one optional argument:\n- `playoffs` - returns **only** the playoffs games if set to `True`\n\nSet to `False` by default.\n\n### Considerations\n- The resulting data frame will use the 'Rk' column as its index\n- The data frame does not include those rows which are just the header again\n- If the player missed a game, the row will be filled with blanks (\"\")\n\n## :basketball: Last n days\nGet a data frame with all the season's available players stats over the last n days by calling `get_n_days(days)`.\n\n### Example\n```\ndf = pb.get_n_days(10)\n```\n### Optional arguments\n`get_n_days` supports one optional argument: \n- `player` - returns a pandas series with the stats of the specifed player\n\n`player` is set to `all` by default.\n\n### Considerations\n- The resulting data frame will have the column 'Players' as its index by default\n- The data frame is in descending order by GmSc\n\n## :basketball: Teams\nYou can call a team's seasons table with `get_team(name)`. The argument `name` is the team's three-letter abbreviation (e.g. OKC, MAV).\n\n### Example\nTo get OKC's table:\n```\ndf = pb.get_team(\"OKC\")\n```\n\n## :basketball: Generate player code\nBaskteball-reference uses a special code to build each player's unique html page. As of now, *almost* all functions in `PandasBasketball` expect that code to get the stats for the specified athlete. If you don't want to copy and paste the code from the URL into the function you can try calling `pb.generate_code(player)`. \n\n**Note:** this is not fully tested, so it is possible to get an incorrect code.\n\n### Example\nTo get the player code for LeBronJames:\n```\npb.generate_code(\"LeBron James\")\n```\nThis will output `'jamesle01'` \n\nUsing it with other functions:\n```\ndf = pb.get_player(pb.generate_code(\"Donovan Mitchell\"), \"per_game\")\n```\n\n\n# Future\n- Make this project pip-installable\n- Add support for the rest of tables on a player's page\n- Implement function to obtain team stats per season\n- ~~Implement function to get the last n days stats~~\n- Implement function to obtain game results by date\n\n# Contributions & Known Issues\nIf you notice an issue or want to contribute open an issue over at the [issues section](https://github.com/alfremedpal/PandasBasketball/issues).\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alfremedpal/PandasBasketball", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "PandasBasketball", "package_url": "https://pypi.org/project/PandasBasketball/", "platform": "", "project_url": "https://pypi.org/project/PandasBasketball/", "project_urls": { "Homepage": "https://github.com/alfremedpal/PandasBasketball" }, "release_url": "https://pypi.org/project/PandasBasketball/0.0.1/", "requires_dist": [ "requests", "beautifulsoup4", "pandas" ], "requires_python": "", "summary": "A Python module to scrape data from basketbal-reference.com and convert it to pandas data structures for analysis.", "version": "0.0.1" }, "last_serial": 5699136, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "00837aaba6811ef691dd7d043cdac00d", "sha256": "d81f9d2c1e54f7e4f49b981fdb6413142a1778d4681a2a5bb6158d9dc8fa5bd7" }, "downloads": -1, "filename": "PandasBasketball-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "00837aaba6811ef691dd7d043cdac00d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7152, "upload_time": "2019-08-19T15:47:29", "url": "https://files.pythonhosted.org/packages/c3/55/321f63f97ce182fc0a4efe4aae615ebe618e7be7be2d66ee20767b6092ba/PandasBasketball-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ef557422d93fec4f1104888c89da951", "sha256": "9bdc448279840bb23a6912d6242bd6e9d606d9341779cd11adc40dc6eddacc97" }, "downloads": -1, "filename": "PandasBasketball-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3ef557422d93fec4f1104888c89da951", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5526, "upload_time": "2019-08-19T15:47:31", "url": "https://files.pythonhosted.org/packages/ae/c2/6827f2ee0aa2dce63489c1630c81b4f09ff88fba4370edacac56cacc5b6a/PandasBasketball-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "00837aaba6811ef691dd7d043cdac00d", "sha256": "d81f9d2c1e54f7e4f49b981fdb6413142a1778d4681a2a5bb6158d9dc8fa5bd7" }, "downloads": -1, "filename": "PandasBasketball-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "00837aaba6811ef691dd7d043cdac00d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7152, "upload_time": "2019-08-19T15:47:29", "url": "https://files.pythonhosted.org/packages/c3/55/321f63f97ce182fc0a4efe4aae615ebe618e7be7be2d66ee20767b6092ba/PandasBasketball-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ef557422d93fec4f1104888c89da951", "sha256": "9bdc448279840bb23a6912d6242bd6e9d606d9341779cd11adc40dc6eddacc97" }, "downloads": -1, "filename": "PandasBasketball-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3ef557422d93fec4f1104888c89da951", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5526, "upload_time": "2019-08-19T15:47:31", "url": "https://files.pythonhosted.org/packages/ae/c2/6827f2ee0aa2dce63489c1630c81b4f09ff88fba4370edacac56cacc5b6a/PandasBasketball-0.0.1.tar.gz" } ] }