Skip to content

Commit

Permalink
Merge pull request #27 from armstjc/16-implement-the-players-endpoint…
Browse files Browse the repository at this point in the history
…s-into-this-python-package

16 implement the players endpoints into this python package
  • Loading branch information
armstjc authored Nov 4, 2023
2 parents b37645e + fe03f9d commit f99837b
Show file tree
Hide file tree
Showing 11 changed files with 12,295 additions and 3,923 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# CHANGELOG: cfbd_json_py

## 0.0.11: The "Players" Update

- Implemented `cfbd_json_py.players.get_cfbd_transfer_portal_data()`, a function that allows a user to get transfer portal data from the CFBD API.
- Implemented `cfbd_json_py.players.get_cfbd_player_season_stats()`, a function that allows a user to get player season stats from the CFBD API.
- Implemented `cfbd_json_py.players.get_cfbd_returning_production()`, a function that allows a user to get returning production data from the CFBD API.
- Implemented `cfbd_json_py.players.get_cfbd_player_usage()`, a function that allows a user to get player usage data from the CFBD API.
- Implemented `cfbd_json_py.players.get_cfbd_pregame_win_probability_data()`, a function that allows a user to lookup known players in the CFBD API.
- Updated the function descriptions for `cfbd_json_py.games.get_cfbd_player_game_stats()`, and added a `["season"]` column to the function's output, should `return_as_dict = False`.
- Updated the validation logic for the `season` input variable for the following functions, by alowing a user to lookup data for the next CFB season:
- `cfbd_json_py.drives.get_cfbd_drives_info()`
- `cfbd_json_py.games.get_cfbd_games()`
- `cfbd_json_py.games.get_cfbd_season_weeks()`
- `cfbd_json_py.games.get_cfbd_game_media_info()`
- `cfbd_json_py.games.get_cfbd_player_game_stats()`
- `cfbd_json_py.metrics.get_cfbd_team_season_ppa_data()`
- `cfbd_json_py.metrics.get_cfbd_team_game_ppa_data()`
- `cfbd_json_py.metrics.get_cfbd_player_game_ppa_data()`
- `cfbd_json_py.metrics.get_cfbd_player_season_ppa_data()`
- `cfbd_json_py.metrics.get_cfbd_pregame_win_probability_data()`
- `cfbd_json_py.metrics.get_cfbd_pregame_win_probability_data()`
- Updated the package version to `0.0.11`.

## 0.0.10: The "Metrics" Update

- Implemented `cfbd_json_py.metrics.get_cfbd_pregame_win_probability_data()`, a function that allows a user to get pregame win probability data from the CFBD API.
Expand Down
4 changes: 2 additions & 2 deletions cfbd_json_py/drives.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Creation Date: 08/30/2023 01:13 EDT
# Last Updated Date: 10/23/2023 04:09 PM EDT
# Last Updated Date: 11/04/2023 02:55 PM EDT
# Author: Joseph Armstrong ([email protected])
# File Name: drives.py
# Purpose: Houses functions pertaining to CFB drive data within the CFBD API.
Expand Down Expand Up @@ -417,7 +417,7 @@ def get_cfbd_drives_info(
"\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down
38 changes: 25 additions & 13 deletions cfbd_json_py/games.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Creation Date: 08/30/2023 01:13 EDT
# Last Updated Date: 10/23/2023 04:09 PM EDT
# Last Updated Date: 11/04/2023 02:55 PM EDT
# Author: Joseph Armstrong ([email protected])
# File Name: games.py
# Purpose: Houses functions pertaining to CFB game data within the CFBD API.
Expand Down Expand Up @@ -367,7 +367,7 @@ def get_cfbd_games(
"\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -932,7 +932,7 @@ def get_cfbd_season_weeks(
"\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -1312,7 +1312,7 @@ def get_cfbd_game_media_info(
"\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -1437,9 +1437,9 @@ def get_cfbd_player_game_stats(
----------
`season` (int, mandatory):
Required argument.
Specifies the season you want CFB media information from.
Specifies the season you want CFB player game stats from.
This must be specified, otherwise this package, and by extension
the CFBD API, will not accept the request to get CFB media information.
the CFBD API, will not accept the request to get CFB player game stats.
`api_key` (str, optional):
Semi-optional argument.
Expand All @@ -1460,7 +1460,7 @@ def get_cfbd_player_game_stats(
`season_type` (str, semi-optional):
Semi-optional argument.
By defualt, this will be set to "regular", for the CFB regular season.
If you want CFB media information for non-regular season games,
If you want CFB player game stats for non-regular season games,
set `season_type` to "postseason".
If `season_type` is set to anything but "regular" or "postseason",
a `ValueError()` will be raised.
Expand All @@ -1471,20 +1471,20 @@ def get_cfbd_player_game_stats(
`week` (int, optional):
Optional argument.
If `week` is set to an integer, this function will attempt
to load CFB media information from games in that season, and in that week.
to load CFB player game stats from games in that season, and in that week.
`team` (str, optional):
Optional argument.
If you only want CFB media information for a team,
If you only want CFB player game stats for a team,
regardless if they are the home/away team,
set `team` to the name of the team you want CFB media information from.
set `team` to the name of the team you want CFB player game stats from.
`conference_abv` (str, optional):
Optional argument.
If you only want media information from games
If you only want player game stats from games
involving teams a specific confrence,
set `conference_abv` to the abbreviation
of the conference you want game information from.
of the conference you want stats from.
`stat_category` (str, optional):
Optional argument.
Expand Down Expand Up @@ -1693,6 +1693,7 @@ def get_cfbd_player_game_stats(
row_df = pd.DataFrame()
url = "https://api.collegefootballdata.com/games/players"
stat_columns = [
'season',
'game_id',
'team_name',
'team_confrence',
Expand Down Expand Up @@ -1796,7 +1797,7 @@ def get_cfbd_player_game_stats(
"please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -3069,12 +3070,14 @@ def get_cfbd_player_game_stats(
"kicking_XPA": "int"
})
# print(cfb_games_df.columns)
cfb_games_df['season'] = season

if filter_by_stat_category == False:
cfb_games_df = cfb_games_df.reindex(columns=stat_columns)

elif filter_by_stat_category == True and stat_category == "passing":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3094,6 +3097,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "rushing":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3110,6 +3114,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "receiving":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3126,6 +3131,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "fumbles":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3140,6 +3146,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "defensive":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3158,6 +3165,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "interceptions":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3172,6 +3180,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "punting":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3189,6 +3198,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "kicking":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3209,6 +3219,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "kickReturns":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand All @@ -3225,6 +3236,7 @@ def get_cfbd_player_game_stats(

elif filter_by_stat_category == True and stat_category == "puntReturns":
cfb_games_df = cfb_games_df[[
'season',
'game_id',
'team_name',
'team_confrence',
Expand Down
12 changes: 6 additions & 6 deletions cfbd_json_py/metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Creation Date: 08/30/2023 01:13 EDT
# Last Updated Date: 10/27/2023 10:54 AM EDT
# Last Updated Date: 11/04/2023 02:55 PM EDT
# Author: Joseph Armstrong ([email protected])
# File Name: metrics.py
# Purpose: Houses functions pertaining to various CFB stats within the CFBD API.
Expand Down Expand Up @@ -490,7 +490,7 @@ def get_cfbd_team_season_ppa_data(
# Rare, but in this endpoint,
# you don't need to input the season.
pass
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -883,7 +883,7 @@ def get_cfbd_team_game_ppa_data(
"\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -1306,7 +1306,7 @@ def get_cfbd_player_game_ppa_data(
"\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
"https://github.com/armstjc/cfbd-json-py/issues"
)
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -1768,7 +1768,7 @@ def get_cfbd_player_season_ppa_data(

if season == None:
pass
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down Expand Up @@ -2350,7 +2350,7 @@ def get_cfbd_pregame_win_probability_data(

if season == None:
pass
elif season > now.year:
elif season > (now.year + 1):
raise ValueError(f"`season` cannot be greater than {season}.")
elif season < 1869:
raise ValueError(f"`season` cannot be less than 1869.")
Expand Down
Loading

0 comments on commit f99837b

Please sign in to comment.