Skip to content

Commit

Permalink
Add WNBA static data. (#444)
Browse files Browse the repository at this point in the history
* Create WnbaSeasonYear and WnbaSeason classes, since WNBA seasons are contained within a single year.

* Update static_players_update script to fetch WNBA players.

* Actual updates to static data, including new WNBA data.

* Update static players library to support WNBA data.

* Update static teams library to support WNBA data.

* Write a small unit test.

* Update examples.
  • Loading branch information
cosmicac authored Jun 10, 2024
1 parent ed67c30 commit 5ed2cb1
Show file tree
Hide file tree
Showing 10 changed files with 1,584 additions and 117 deletions.
10 changes: 8 additions & 2 deletions docs/nba_api/stats/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ lebron_james = {
}
```

All three of these searches will return a list of players.
All three of these searches will return a list of players. Corresponding functions exist for WNBA players as well.

```python
from nba_api.stats.static import players
Expand All @@ -108,14 +108,17 @@ players.find_players_by_last_name('^(james|love)$')

# Get all players.
players.get_players()

# Get all players in the WNBA.
players.get_wnba_players()
```

In addition, you can find players by ID by using `find_player_by_id()`. `get_active_players()` and `get_inactive_players()` will return a list of only active and only inactive players, respectively.


### Teams

You can also find teams using regex patterns on fields such as full name, state, city, and nickname. As well as finding teams by year founded, abbreviation, and id.
You can also find teams using regex patterns on fields such as full name, state, city, and nickname. As well as finding teams by year founded, abbreviation, and id. Corresponding functions exist for WNBA players as well.

```python
from nba_api.stats.static import teams
Expand Down Expand Up @@ -143,4 +146,7 @@ teams.find_team_name_by_id(1610612739)

# Get all teams.
teams.get_teams()

# Get all WNBA teams.
teams.get_wnba_teams()
```
53 changes: 51 additions & 2 deletions docs/nba_api/stats/static/players.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@
The purpose of this module is to access player information without having to submit requests.

## `_find_players`(_`regex_pattern`_, _`row_id`_)
## `_find_players`(_`regex_pattern`_, _`row_id`_, _`players=players`_)

This is a protected function used to help search regex patterns through the players list.
This is a protected function used to help search regex patterns through the players list. The
`players` parameter defaults to NBA players, but `wnba_players` can be passed in.

## `_find_player_by_id`(_`player_id`_, _`players=players`_)

This is a protected function used to help search for players by ID. The `players` parameter defaults
to NBA players, but `wnba_players` can be passed in.

## `_get_players`(_`players=players`_)

This is a protected function used to get all players. The `players` parameter defaults
to NBA players, but `wnba_players` can be passed in.

## `_get_active_players`(_`players=players`_)

This is a protected function used to get active players. The `players` parameter defaults
to NBA players, but `wnba_players` can be passed in.

## `_get_inactive_players`(_`players=players`_)

This is a protected function used to get inactive players. The `players` parameter defaults
to NBA players, but `wnba_players` can be passed in.

## `_get_player_dict`(_`player_row`_)
```python
Expand Down Expand Up @@ -46,3 +67,31 @@ Returns a list of all active players.
## `get_inactive_players`()

Returns a list of all inactive players.

## `find_wnba_players_by_full_name`(_`regex_pattern`_)

Returns a list of WNBA players where full names match the provided `regex pattern`.

## `find_wnba_players_by_first_name`(_`regex_pattern`_)

Returns a list of WNBA players where first names match the provided `regex pattern`.

## `find_wnba_players_by_last_name`(_`regex_pattern`_)

Returns a list of WNBA players where last names match the provided `regex pattern`.

## `find_wnba_player_by_id`(_`player_id`_)

Returns a WNBA player that matches the player id provided. Function will fail on any multiple matches. This means our player list has a duplicate or there's an error in the function. No matches will return a `null` value.

## `get_wnba_players`()

Returns a list of all WNBA players.

## `get_wnba_active_players`()

Returns a list of all active WNBA players.

## `get_wnba_inactive_players`()

Returns a list of all inactive WNBA players.
65 changes: 62 additions & 3 deletions docs/nba_api/stats/static/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,29 @@
The purpose of this module is to access team information without having to submit requests.

## `_find_teams`(_`regex_pattern`_, _`row_id`_)
## `_find_teams`(_`regex_pattern`_, _`row_id`_, _`teams=teams`_)

This is a protected function used to help search regex patterns through the teams list.
This is a protected function used to help search regex patterns through the teams list. The `teams` parameter defaults to NBA teams, but `wnba_teams` can be passed in.

## `_find_team_name_by_id`(_`team_id`_, _`teams=teams`_)

This is a protected function used to find a team by ID. The `teams` parameter defaults to NBA teams, but `wnba_teams` can be passed in.

## `_find_team_by_abbreviation`(_`abbreviation`_, _`teams=teams`_)

This is a protected function used to find a team by abbreviation. The `teams` parameter defaults to NBA teams, but `wnba_teams` can be passed in.

## `_find_teams_by_championship_year`(_`year`_, _`teams=teams`_)

This is a protected function used to find a team by championship year. The `teams` parameter defaults to NBA teams, but `wnba_teams` can be passed in.

## `_find_teams_by_year_founded`(_`year`_, _`teams=teams`_)

This is a protected function used to find a team by year founded. The `teams` parameter defaults to NBA teams, but `wnba_teams` can be passed in.

## `_get_teams`(_`teams=teams`_)

This is a protected function used to get all teams. The `teams` parameter defaults to NBA teams, but `wnba_teams` can be passed in.

## `_get_team_dict`(_`team_row`_)
```python
Expand Down Expand Up @@ -41,14 +61,53 @@ Returns a list of teams where the nickname matches the provided `regex pattern`.

Returns a list of teams that matches the year provided.

## `find_teams_by_championship_year`(_`year`_)

Returns a list of teams that matches the championship year provided.

## `find_team_by_abbreviation`(_`abbreviation`_)

Returns a team that matches the abbreviation provided. Function will fail on any multiple matches. This means our team list has a duplicate or there's an error in the function. No matches will return a `null` value.

## `find_team_name_by_id`(_`player_id`_)
## `find_team_name_by_id`(_`team_id`_)

Returns a team that matches the team id provided. Function will fail on any multiple matches. This means our team list has a duplicate or there's an error in the function. No matches will return a `null` value.

## `get_teams`(_`regex_pattern`_, _`row_id`_)

Returns a list of all teams.

## `find_wnba_teams_by_full_name`(_`regex_pattern`_)

Returns a list of WNBA teams where full team name matches the provided `regex pattern`.
## `find_wnba_teams_by_state`(_`regex_pattern`_)

Returns a list of WNBA teams where the state matches the provided `regex pattern`.

## `find_wnba_teams_by_city`(_`regex_pattern`_)

Returns a list of WNBA teams where the city matches the provided `regex pattern`.

## `find_wnba_teams_by_nickname`(_`regex_pattern`_)

Returns a list of WNBA teams where the nickname matches the provided `regex pattern`.

## `find_wnba_teams_by_year_founded`(_`year`_)

Returns a list of WNBA teams that matches the year provided.

## `find_wnba_teams_by_championship_year`(_`year`_)

Returns a list of WNBA teams that matches the championship year provided.

## `find_wnba_team_by_abbreviation`(_`abbreviation`_)

Returns a WNBA team that matches the abbreviation provided. Function will fail on any multiple matches. This means our team list has a duplicate or there's an error in the function. No matches will return a `null` value.

## `find_wnba_team_name_by_id`(_`team_id`_)

Returns a WNBA team that matches the team id provided. Function will fail on any multiple matches. This means our team list has a duplicate or there's an error in the function. No matches will return a `null` value.

## `get_wnba_teams`()

Returns a list of all WNBA teams.
Loading

0 comments on commit 5ed2cb1

Please sign in to comment.