Name | usports-basketball JSON |
Version |
2.0.1
JSON |
| download |
home_page | None |
Summary | A Python package for current U Sports basketball stats. |
upload_time | 2024-09-07 03:44:06 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 OJ Adeyemi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
basketball
usports
statistics
data analysis
web scraping
python package
pandas
beautifulsoup
playwright
sports analytics
college basketball
developer tools
data fetching
|
VCS |
|
bugtrack_url |
|
requirements |
beautifulsoup4
numpy
pandas
playwright
pytest
requests
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 🏀 usports-basketball
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![PyPI Latest Release](https://img.shields.io/pypi/v/usports-basketball?color=orange)](https://pypi.org/project/usports-basketball/)
[![License](https://img.shields.io/pypi/l/usports-basketball.svg)](https://github.com/ojadeyemi/usports-basketball/blob/main/LICENSE)
[![Downloads](https://static.pepy.tech/badge/usports-basketball)](https://pepy.tech/project/usports-basketball)
[![Package Status](https://img.shields.io/pypi/status/usports-basketball.svg)](https://pypi.org/project/usports-basketball/)
**usports-basketball** is a Python package that fetches and analyzes current basketball stats from the [U Sports website](https://usports.ca/en).
With two simple functions you can easily retrieve detailed data for either the men's or women's league.
- `usport_teams_stats`: Fetch team stats.
- `usport_players_stats`: Fetch player stats.
Each function returns a pandas DataFrame with the relevant statistics, allowing users to gather data for analysis and insights.
## 📥 Installation
You can install the package via pip:
```bash
pip install usports-basketball
```
## 🧩 Dependencies
This package relies on the following dependencies:
- pandas
- BeautifulSoup (bs4)
- requests
- pytest
- playwright
## Installing Chromium for Playwright
After installing the package, you'll need to install Playwright's Chromium browser. Run the following command:
```bash
playwright install chromium
```
## Functions
### `usport_teams_stats`
This function fetches and processes team statistics data, including standings, win-loss totals, shooting percentages, and other relevant team metrics for the current U Sports basketball season.
#### Parameters
- `arg` (str): The league for which you want to retrieve team statistics. Valid values are `'men'` and `'women'` or `'m'` and `'w'` (case-insensitive).
- `season_option` (str, optional): The season type to fetch data for. Options are:
- `'regular'` (default): Regular season statistics.
- `'playoffs'`: Playoff season statistics.
- `'championship'`: Championship season statistics.
#### Returns
- `DataFrame`: A pandas DataFrame containing the team statistics data.
### `usports_player_stats`
This function fetches and processes player statistics data, including total games played, points scored, shooting percentages, rebounds, assists, turnovers, steals, blocks, and other individual player metrics for the current U Sports basketball season.
#### Parameters
- `arg` (str): The league for which you want to retrieve team statistics. Valid values are `'men'` and `'women'` or `'m'` and `'w'` (case-insensitive).
- `season_option` (str, optional): The season type to fetch data for. Options are:
- `'regular'` (default): Regular season statistics.
- `'playoffs'`: Playoff season statistics.
- `'championship'`: Championship season statistics.
#### Returns
- `DataFrame`: A pandas DataFrame containing the player statistics data.
## Usage
- ### Fetching current stats from the league
```python
from usports_basketball import usport_teams_stats, usports_player_stats
# Fetching and processing men's team statistics
men_team_stats_df = usport_teams_stats('m')
# Fetching and processing men's player statistics
men_player_stats_df = usport_players_stats('m')
# Fetch statistics for women's playoff teams
women_team_stats_df = usport_teams_stats('w', 'playoffs')
# Fetch statistics for women's players playing in U Sports championship Final 8
women_player_stats_df = usport_players_stats('w', 'championship')
```
- ### Viewing Column Names
```python
# Use these code snippets to see all column names in each DataFrame
# For the team statistics DataFrame
print("Column names in men's player statistics DataFrame:")
print(men_player_stats_df.columns.tolist())
# For the player statistics DataFrame
print("\nColumn names in men's player statistics DataFrame:")
print(men_player_stats_df.columns.tolist())
```
- ### Exporting DataFrame to different files
```python
# Export the to a CSV file using the `to_csv()` method
men_team_stats_df.to_csv('men_team_stats.csv', index=False) # Export without row index
#Export to a HTML table representation using to_html method
men_team_stats_df.to_html('table.html')
#Export to a JSON file using the to_json() method
men_team_stats_df.to_json('men_team_stats.json', orient='records') # Export in 'records' format
#Export to a SQLite database using the to_sql() method (requires SQLAlchemy)
from sqlalchemy import create_engine
engine = create_engine('sqlite:///usports_stats.db') #Export to SQLite database
women_team_stats_df.to_sql('team_stats', con=engine, index=False) # Export without row index
women_player_stats_df.to_sql('player_stats', con=engine, index=False) # Export without row index
```
### Explore [Pandas DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) documentation for instructions on manipulating data and performing data analysis.
## Author
This package was developed by OJ Adeyemi.
## Contributing
Contributions, bug reports, and feature requests are welcome! Please feel free to open an issue or submit a pull request on [GitHub](https://github.com/ojadeyemi/usports-basketball).
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "usports-basketball",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "basketball, usports, statistics, data analysis, web scraping, python package, pandas, beautifulsoup, playwright, sports analytics, college basketball, developer tools, data fetching",
"author": null,
"author_email": "OJ Adeyemi <ojieadeyemi@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/dc/d5/6b1d44c67a1a4e109eea93c477b4ce1b2aeee9db09afbacae6dce272f7c1/usports_basketball-2.0.1.tar.gz",
"platform": null,
"description": "# \ud83c\udfc0 usports-basketball \n\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![PyPI Latest Release](https://img.shields.io/pypi/v/usports-basketball?color=orange)](https://pypi.org/project/usports-basketball/) \n[![License](https://img.shields.io/pypi/l/usports-basketball.svg)](https://github.com/ojadeyemi/usports-basketball/blob/main/LICENSE) \n[![Downloads](https://static.pepy.tech/badge/usports-basketball)](https://pepy.tech/project/usports-basketball) \n[![Package Status](https://img.shields.io/pypi/status/usports-basketball.svg)](https://pypi.org/project/usports-basketball/)\n\n**usports-basketball** is a Python package that fetches and analyzes current basketball stats from the [U Sports website](https://usports.ca/en). \n\nWith two simple functions you can easily retrieve detailed data for either the men's or women's league. \n- `usport_teams_stats`: Fetch team stats.\n- `usport_players_stats`: Fetch player stats.\n\nEach function returns a pandas DataFrame with the relevant statistics, allowing users to gather data for analysis and insights.\n\n## \ud83d\udce5 Installation\n\nYou can install the package via pip:\n\n```bash\npip install usports-basketball\n```\n\n## \ud83e\udde9 Dependencies\n\nThis package relies on the following dependencies:\n\n- pandas\n- BeautifulSoup (bs4)\n- requests\n- pytest\n- playwright\n\n## Installing Chromium for Playwright\n\nAfter installing the package, you'll need to install Playwright's Chromium browser. Run the following command:\n\n```bash\nplaywright install chromium\n```\n\n## Functions\n\n### `usport_teams_stats`\n\nThis function fetches and processes team statistics data, including standings, win-loss totals, shooting percentages, and other relevant team metrics for the current U Sports basketball season.\n\n#### Parameters\n\n- `arg` (str): The league for which you want to retrieve team statistics. Valid values are `'men'` and `'women'` or `'m'` and `'w'` (case-insensitive).\n- `season_option` (str, optional): The season type to fetch data for. Options are:\n - `'regular'` (default): Regular season statistics.\n - `'playoffs'`: Playoff season statistics.\n - `'championship'`: Championship season statistics.\n\n#### Returns\n\n- `DataFrame`: A pandas DataFrame containing the team statistics data.\n\n### `usports_player_stats`\n\nThis function fetches and processes player statistics data, including total games played, points scored, shooting percentages, rebounds, assists, turnovers, steals, blocks, and other individual player metrics for the current U Sports basketball season.\n\n#### Parameters\n\n- `arg` (str): The league for which you want to retrieve team statistics. Valid values are `'men'` and `'women'` or `'m'` and `'w'` (case-insensitive).\n- `season_option` (str, optional): The season type to fetch data for. Options are:\n - `'regular'` (default): Regular season statistics.\n - `'playoffs'`: Playoff season statistics.\n - `'championship'`: Championship season statistics.\n\n#### Returns\n\n- `DataFrame`: A pandas DataFrame containing the player statistics data.\n\n## Usage\n\n- ### Fetching current stats from the league\n\n```python\nfrom usports_basketball import usport_teams_stats, usports_player_stats\n\n# Fetching and processing men's team statistics\nmen_team_stats_df = usport_teams_stats('m')\n\n# Fetching and processing men's player statistics\nmen_player_stats_df = usport_players_stats('m')\n\n# Fetch statistics for women's playoff teams\nwomen_team_stats_df = usport_teams_stats('w', 'playoffs')\n\n# Fetch statistics for women's players playing in U Sports championship Final 8\nwomen_player_stats_df = usport_players_stats('w', 'championship')\n```\n\n- ### Viewing Column Names\n\n```python\n# Use these code snippets to see all column names in each DataFrame\n# For the team statistics DataFrame\nprint(\"Column names in men's player statistics DataFrame:\")\nprint(men_player_stats_df.columns.tolist())\n\n# For the player statistics DataFrame\nprint(\"\\nColumn names in men's player statistics DataFrame:\")\nprint(men_player_stats_df.columns.tolist())\n```\n\n\n- ### Exporting DataFrame to different files\n\n```python\n# Export the to a CSV file using the `to_csv()` method\nmen_team_stats_df.to_csv('men_team_stats.csv', index=False) # Export without row index\n\n#Export to a HTML table representation using to_html method\nmen_team_stats_df.to_html('table.html')\n\n#Export to a JSON file using the to_json() method\nmen_team_stats_df.to_json('men_team_stats.json', orient='records') # Export in 'records' format\n\n#Export to a SQLite database using the to_sql() method (requires SQLAlchemy)\nfrom sqlalchemy import create_engine\n\nengine = create_engine('sqlite:///usports_stats.db') #Export to SQLite database\nwomen_team_stats_df.to_sql('team_stats', con=engine, index=False) # Export without row index\nwomen_player_stats_df.to_sql('player_stats', con=engine, index=False) # Export without row index\n```\n\n### Explore [Pandas DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) documentation for instructions on manipulating data and performing data analysis.\n\n## Author\n\nThis package was developed by OJ Adeyemi.\n\n## Contributing\n\nContributions, bug reports, and feature requests are welcome! Please feel free to open an issue or submit a pull request on [GitHub](https://github.com/ojadeyemi/usports-basketball).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\nfor details.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 OJ Adeyemi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A Python package for current U Sports basketball stats.",
"version": "2.0.1",
"project_urls": {
"Changelog": "https://github.com/ojadeyemi/usports-basketball/blob/main/CHANGELOG.md",
"Issues": "https://github.com/ojadeyemi/usports-basketball/issues",
"Repository": "https://github.com/ojadeyemi/usports-basketball.git"
},
"split_keywords": [
"basketball",
" usports",
" statistics",
" data analysis",
" web scraping",
" python package",
" pandas",
" beautifulsoup",
" playwright",
" sports analytics",
" college basketball",
" developer tools",
" data fetching"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6b4e34c79af3b4421fef7689e5e3ac4bb0e26eb3566306c4f5fa0a6c9f2e071c",
"md5": "09982045d75a34b68c5ab4f0d5c8f4d5",
"sha256": "c3d6bee459c120aa84c9f8a2e6d243d875c108bb353da53d6536a11886b77920"
},
"downloads": -1,
"filename": "usports_basketball-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "09982045d75a34b68c5ab4f0d5c8f4d5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21540,
"upload_time": "2024-09-07T03:44:05",
"upload_time_iso_8601": "2024-09-07T03:44:05.024856Z",
"url": "https://files.pythonhosted.org/packages/6b/4e/34c79af3b4421fef7689e5e3ac4bb0e26eb3566306c4f5fa0a6c9f2e071c/usports_basketball-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dcd56b1d44c67a1a4e109eea93c477b4ce1b2aeee9db09afbacae6dce272f7c1",
"md5": "c5f52307382f76189570a06ed65568c6",
"sha256": "3eb3d38a2d261d0bdeb6a03dc2d08bab82ab2dad3b4db454a362f3d918e9fc11"
},
"downloads": -1,
"filename": "usports_basketball-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "c5f52307382f76189570a06ed65568c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 18207,
"upload_time": "2024-09-07T03:44:06",
"upload_time_iso_8601": "2024-09-07T03:44:06.480346Z",
"url": "https://files.pythonhosted.org/packages/dc/d5/6b1d44c67a1a4e109eea93c477b4ce1b2aeee9db09afbacae6dce272f7c1/usports_basketball-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-07 03:44:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ojadeyemi",
"github_project": "usports-basketball",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "beautifulsoup4",
"specs": [
[
"==",
"4.12.3"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"2.0.1"
]
]
},
{
"name": "pandas",
"specs": [
[
"==",
"2.2.2"
]
]
},
{
"name": "playwright",
"specs": [
[
"==",
"1.45.1"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"8.3.2"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
}
],
"lcname": "usports-basketball"
}