A package for scraping NBA stats from yahoo
Project description
This is a package to get NBA stats from scraping yahoo.com
There are 2 main classes in this package
- DataAttribute
- Player
- Team
DataAttribute
- this is the return value from most of the Player methods
- Attributes:
- names: list = field(default_factory=list)
- num_game: int = 1
- fg_made: float = 0.0
- fg_attempt: float = 0.0
- three_made: float = 0.0
- three_attempt: float = 0.0
- ft_made: float = 0.0
- ft_attempt: float = 0.0
- rebound: float = 0.0
- assist: float = 0.0
- turnover: float = 0.0
- steal: float = 0.0
- block: float = 0.0
- point: float = 0.0
Player
-
Attributes:
- name (string): player's full name
- player_id (int): player 4 digit id
- game_raw_data (BeautifulSoup object): internal data for processing
- yearly_raw_data (BeautifulSoup object): internal data for processing
- team (string): player's team
- number (int): player's number
- avg_pt (float): average point for current season
- avg_reb (float): average rebound for current season
- avg_ast (float): average assist for current season
- position (string): position
- college (string): college the player attended
-
Methods:
-
get_yearly_data(self, year='current')
- return the yearly average represented by DataAttribute dataclass
- required parameters:
- year (int): a 4 digit formatted year, eg, 2019. If it's "current", it'll get the current year
-
get_recent_games_data(self, game_type='all', home_only=False, away_only=False, games=5, year='current')
- return a list of DataAttribute objects
- required parameters:
- game_type (string): accepted types are all, reg, or post, default=all
- home_only (bool): home game only, default=False
- away_only (bool): away game only, default=False
- games (int): the number of games, default=5
- year (int): a 4 digit formatted year, eg, 2019. If it's "current", it'll get the current year. default=current
-
get_recent_games_avg_stats(self, game_type='all', home_only=False, away_only=False, games=5, year='current')
- return a list of DataAttribute objects
- required parameters:
- game_type (string): accepted types are all, reg, or post, default=all
- home_only (bool): home game only, default=False
- away_only (bool): away game only, default=False
- games (int): the number of games, default=5
- year (int): a 4 digit formatted year, eg, 2019. If it's "current", it'll get the current year. default=current
-
get_data_by_opponentt(self, oppo, game_type='all', year='current')
- return a list of DataAttribute objects
- required parameters:
- game_type (string): accepted types are all, reg, or post, default=all
- home_only (bool): home game only, default=False
- away_only (bool): away game only, default=False
- games (int): the number of games, default=5
- year (int): a 4 digit formatted year, eg, 2019. If it's "current", it'll get the current year. default=current
-
get_avg_stats_by_opponent(self, oppo, game_type='all', year='current')
- return the average stats against a particular opponent represented by DataAttribute dataclass
- required parameters:
- oppo (string): the 3 charater team name, eg, "BKN"
- game_type (string): accepted types are all, reg, or post, default=all
- year (int): a 4 digit formatted year, eg, 2019. If it's "current", it'll get the current year. default=current
-
clear_cache(self)
- clear caches
- requred parameters:
- None
-
Team
- Attributes:
- name (string): team name
- win (int): number of wins for current season
- loss (int): number of loss for current season
- pt (float): average point
- reb (float): average rebound
- fg (float): average fild goal percentage
- percent_3pt (float): average 3 point percentage
- standing (string): team standing
- raw_data (BeautifulSoup object): internal data for processing
- players (list[Player]): list of player objects
Example
-
from nba_stats import nba_stats player = nba_stats.Player('Stephen Curry') player.get_yearly_data() DataAttribute(names=['2020-21'], num_game='4', fg_made=8.3, fg_attempt=20.0, three_made=3.5, three_attempt=11.0, ft_made=6.5, ft_attempt=6.5, rebound=3.8, assist=7.0, turnover=4.3, steal=1.8, block=0.5, point=26.5) player.get_avg_stats_by_opponent('CLE', year=2019) DataAttribute(names=['@CLE'], num_game=1, fg_made=6.0, fg_attempt=14.0, three_made=1.0, three_attempt=3.0, ft_made=1.0, ft_attempt=2.0, rebound=6.0, assist=5.0, turnover=2.0, steal=0.0, block=0.0, point=14.0) team = nba_stats.Team('Golden State Warriors') team.pt 111.0 team.win 2
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py-nba-stats-0.0.4.tar.gz.
File metadata
- Download URL: py-nba-stats-0.0.4.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a9c59bfd81f878293b0948b050adf9cb3f4885a082a24cf6147d1119ef52233
|
|
| MD5 |
8c23dd49746e579c3cd6ed27e9d96d69
|
|
| BLAKE2b-256 |
4f492919f0116914c587821ffd1f807a1c1ce608343639dbe79ee9669feaf3d1
|
File details
Details for the file py_nba_stats-0.0.4-py3-none-any.whl.
File metadata
- Download URL: py_nba_stats-0.0.4-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89a123659222b21b32bbf9c1bbdc24be08edc50ea98036e42998e4443f74bcd3
|
|
| MD5 |
ff13f730bedef2f86af2784049ea2d30
|
|
| BLAKE2b-256 |
138c98f7699855919e5677a9f4de561ffae2f8713b2a8e489862ba06d675f908
|