diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d7d126..88f5859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/cfbd_json_py/drives.py b/cfbd_json_py/drives.py index cb72343..6f8b5cb 100644 --- a/cfbd_json_py/drives.py +++ b/cfbd_json_py/drives.py @@ -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 (armstrongjoseph08@gmail.com) # File Name: drives.py # Purpose: Houses functions pertaining to CFB drive data within the CFBD API. @@ -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.") diff --git a/cfbd_json_py/games.py b/cfbd_json_py/games.py index 6da4612..fbd8ea3 100644 --- a/cfbd_json_py/games.py +++ b/cfbd_json_py/games.py @@ -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 (armstrongjoseph08@gmail.com) # File Name: games.py # Purpose: Houses functions pertaining to CFB game data within the CFBD API. @@ -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.") @@ -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.") @@ -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.") @@ -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. @@ -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. @@ -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. @@ -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', @@ -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.") @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', diff --git a/cfbd_json_py/metrics.py b/cfbd_json_py/metrics.py index 9f1ab80..11b912b 100644 --- a/cfbd_json_py/metrics.py +++ b/cfbd_json_py/metrics.py @@ -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 (armstrongjoseph08@gmail.com) # File Name: metrics.py # Purpose: Houses functions pertaining to various CFB stats within the CFBD API. @@ -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.") @@ -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.") @@ -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.") @@ -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.") @@ -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.") diff --git a/cfbd_json_py/players.py b/cfbd_json_py/players.py index 7807ea5..0fa1e80 100644 --- a/cfbd_json_py/players.py +++ b/cfbd_json_py/players.py @@ -1,11 +1,22 @@ # Creation Date: 08/30/2023 01:13 EDT -# Last Updated Date: 10/26/2023 07:45 PM EDT +# Last Updated Date: 11/04/2023 03:09 PM EDT # Author: Joseph Armstrong (armstrongjoseph08@gmail.com) # File Name: players.py # Purpose: Houses functions pertaining to CFB player data within the CFBD API. #################################################################################################### +from datetime import datetime +import logging + +import pandas as pd +import requests +from tqdm import tqdm + +from cfbd_json_py.games import get_cfbd_player_game_stats +from cfbd_json_py.utls import get_cfbd_api_token + + def cfbd_player_search( search_str: str, api_key: str = None, @@ -15,11 +26,313 @@ def cfbd_player_search( season: int = None, return_as_dict: bool = False): """ + Given a string, search for players who's + name matches that string in some capacity. + + Parameters + ---------- + `search_str` (int, mandatory): + Mandatory argument. + This is the name of the player you are trying to find. + + `api_key` (str, optional): + Semi-optional argument. + If `api_key` is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If `api_key` is not null, this function will automatically assume that the + inputted `api_key` is a valid CFBD API key. + + `api_key_dir` (str, optional): + Optional argument. + If `api_key` is set to am empty string, this variable is ignored. + If `api_key_dir` is null, and `api_key` is null, + this function will try to find a CFBD API key file in this user's home directory. + If `api_key_dir` is set to a string, and `api_key` is null, + this function will assume that `api_key_dir` is a directory, + and will try to find a CFBD API key file in that directory. + + `position` (bool, semi-optional): + Semi-optional argument. + If you only want players from a specific position, + set `position` to the position you want to find players from. + + `team` (bool, semi-optional): + Semi-optional argument. + If you only want players from a specific team, + set `team` to the name of the team you want to find players from. + + `season` (bool, semi-optional): + Semi-optional argument. + If you only want players from a specific CFB season, + set `season` to the season you want to find players from. + + `return_as_dict` (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas `DataFrame` object, + set `return_as_dict` to `True`. + + Usage + ---------- + ``` + import time + + from cfbd_json_py.players import cfbd_player_search + + + cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. + + if cfbd_key != "tigersAreAwsome": + print("Using the user's API key declared in this script for this example.") + + # Get a list of every known "Joe" in the CFBD API. + print("Get a list of every known \"Joe\" in the CFBD API.") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="Joe" + ) + print(json_data) + time.sleep(5) + + # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B". + print("Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="Joe B" + ) + print(json_data) + time.sleep(5) + + # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career. + print("Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="Jim", + position="QB" + ) + print(json_data) + time.sleep(5) + + + # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name. + print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="A", + team="Cincinnati" + ) + print(json_data) + time.sleep(5) + + + # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career. + print("Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="Jim", + position="QB" + ) + print(json_data) + time.sleep(5) + + # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason. + print("Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="Joe", + season=2020 + ) + print(json_data) + time.sleep(5) + + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = cfbd_player_search( + api_key=cfbd_key, + search_str="Justin F", + season=2020, + return_as_dict=True + ) + print(json_data) + + else: + # Alternatively, if the CFBD API key exists in this python environment, + # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), + # you could just call these functions directly, without setting the API key + # in the script. + print("Using the user's API key suposedly loaded into this python environment for this example.") + + # Get a list of every known "Joe" in the CFBD API. + print("Get a list of every known \"Joe\" in the CFBD API.") + json_data = cfbd_player_search( + search_str="Joe" + ) + print(json_data) + time.sleep(5) + + # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B". + print("Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".") + json_data = cfbd_player_search( + search_str="Joe B" + ) + print(json_data) + time.sleep(5) + + # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career. + print("Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.") + json_data = cfbd_player_search( + search_str="Jim", + position="QB" + ) + print(json_data) + time.sleep(5) + + + # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name. + print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.") + json_data = cfbd_player_search( + search_str="A", + team="Cincinnati" + ) + print(json_data) + time.sleep(5) + + + # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career. + print("Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.") + json_data = cfbd_player_search( + search_str="Jim", + position="QB" + ) + print(json_data) + time.sleep(5) + + # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason. + print("Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.") + json_data = cfbd_player_search( + search_str="Joe", + season=2020 + ) + print(json_data) + time.sleep(5) + + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = cfbd_player_search( + search_str="Justin F", + season=2020, + return_as_dict=True + ) + print(json_data) + + ``` + Returns + ---------- + A pandas `DataFrame` object with a list of players who matched the search string, + or (if `return_as_dict` is set to `True`) + a dictionary object with a list of players who matched the search string. """ - raise NotImplementedError( - 'This function has yet to be implemented by this version.' - ) + now = datetime.now() + players_df = pd.DataFrame() + row_df = pd.DataFrame() + url = "https://api.collegefootballdata.com/player/search" + + ######################################################################################################################################################################################################## + + if api_key != None: + real_api_key = api_key + del api_key + else: + real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) + + if real_api_key == "tigersAreAwsome": + raise ValueError( + "You actually need to change `cfbd_key` to your CFBD API key.") + elif "Bearer " in real_api_key: + pass + elif "Bearer" in real_api_key: + real_api_key = real_api_key.replace('Bearer', 'Bearer ') + else: + real_api_key = "Bearer " + real_api_key + + if season == None: + # Rare, but in this endpoint, + # you don't need to input the season. + pass + 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.") + + # URL builder + ######################################################################################################################################################################################################## + + # Required by API + url += f"?searchTerm={search_str}" + + url = url.replace(" ", "%20") # For sanity reasons with URLs. + + if position != None: + url += f"&position={position}" + + if team != None: + url += f"&team={team}" + + if season != None: + url += f"&year={season}" + + headers = { + 'Authorization': f'{real_api_key}', + 'accept': 'application/json' + } + + response = requests.get(url, headers=headers) + + if response.status_code == 200: + pass + elif response.status_code == 401: + raise ConnectionRefusedError( + f'Could not connect. The connection was refused.\nHTTP Status Code 401.' + ) + else: + raise ConnectionError( + f'Could not connect.\nHTTP Status code {response.status_code}' + ) + + json_data = response.json() + + if return_as_dict == True: + return json_data + + for player in tqdm(json_data): + p_id = player['id'] + row_df = pd.DataFrame( + {"player_id": p_id}, + index=[0] + ) + row_df['team'] = player['team'] + row_df['player_full_name'] = player['name'] + row_df['player_first_name'] = player['firstName'] + row_df['player_last_name'] = player['lastName'] + row_df['weight_lbs'] = player['weight'] + row_df['height_in'] = player['height'] + row_df['jersey'] = player['jersey'] + row_df['position'] = player['position'] + row_df['hometown'] = player['hometown'] + row_df['team_color_primary'] = player['teamColor'] + row_df['team_color_secondary'] = player['teamColorSecondary'] + + players_df = pd.concat([players_df, row_df], ignore_index=True) + + del row_df + del p_id + + return players_df def get_cfbd_player_usage( @@ -33,27 +346,692 @@ def get_cfbd_player_usage( exclude_garbage_time: bool = False, return_as_dict: bool = False): """ + Get player usage data (A.K.A., the percentages for how often a player touched the ball), + for a given season, at the season level, from the CFBD API. + + Parameters + ---------- + `season` (int, optional): + Mandatory argument. + Specifies the season you want player usage data from. + You MUST set `season` or `team` to a non-null value for + this function to work. If you don't, a `ValueError()` + will be raised. + + `api_key` (str, optional): + Semi-optional argument. + If `api_key` is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If `api_key` is not null, this function will automatically assume that the + inputted `api_key` is a valid CFBD API key. + + `api_key_dir` (str, optional): + Optional argument. + If `api_key` is set to am empty string, this variable is ignored. + If `api_key_dir` is null, and `api_key` is null, + this function will try to find a CFBD API key file in this user's home directory. + If `api_key_dir` is set to a string, and `api_key` is null, + this function will assume that `api_key_dir` is a directory, + and will try to find a CFBD API key file in that directory. + + `team` (str, optional): + Semi-ptional argument. + If you only want player usage data for a specific team, + set `team` to the name of the team you want player usage data from. + You MUST set `season` or `team` to a non-null value for + this function to work. If you don't, a `ValueError()` + will be raised. + + `position` (str, optional): + Semi-Optional argument. + If you only want player usage data + for players who played a specific position, + set `position` to that position's abbreviation. + A list of CFBD API positions can be found in the `position_abbreviation` column from + the pandas DataFrame that is returned by calling `cfbd_json_py.draft.get_cfbd_nfl_positions()`. + + `conference_abv` (str, optional): + Optional argument. + If you only want player usage data from games + involving teams from a specific confrence, + set `conference_abv` to the abbreviation + of the conference you want player usage data from. + For a list of confrences, + use the `cfbd_json_py.conferences.get_cfbd_conference_info()` + function. + + `player_id` (int, optional): + Optional argument. + If you only want player usage data for a specific player ID, + set this variable to the player ID of the player you want player usage data from. + + `exclude_garbage_time` (bool, optional): + Optional argument. + If you want to filter out plays where the result of the game is largely decided, + set `exclude_garbage_time = True`. + Default behavior is that this variable is set to + `False` when this function is called. + + `return_as_dict` (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas `DataFrame` object, + set `return_as_dict` to `True`. + + Usage + ---------- + ``` + import time + + from cfbd_json_py.players import get_cfbd_player_usage + + + cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. + + if cfbd_key != "tigersAreAwsome": + print("Using the user's API key declared in this script for this example.") + + # Get player usage data from the 2020 CFB season. + print("Get player usage data from the 2020 CFB season.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2020 + ) + print(json_data) + time.sleep(5) + + # Get player usage data for the + # University of Cincinnati Bearcats Football Team, + # during the 2020 CFB season. + print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2020, + team="Cincinnati" + ) + print(json_data) + time.sleep(5) + + # Get player usage data from players who + # primarily played running back (RB) in the 2020 CFB season. + print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2020, + position="RB" + ) + print(json_data) + time.sleep(5) + + # Get player usage data from players who played on + # Big 10 Confrence (B1G) teams during the 2020 CFB Season. + print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2020, + conference_abv="B1G" + ) + print(json_data) + time.sleep(5) + + # Get player usage data from + # former LSU Tigers quarterback Joe Burrow (player ID #3915511), + # during the 2019 CFB season. + print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2019, + player_id=3915511 + ) + print(json_data) + time.sleep(5) + + # Get player usage data from + # former LSU Tigers quarterback Joe Burrow (player ID #3915511), + # during the 2019 CFB season, + # but filter out plays that occured in garbage time. + print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2019, + player_id=3915511, + exclude_garbage_time=True + ) + print(json_data) + time.sleep(5) + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = get_cfbd_player_usage( + api_key=cfbd_key, + season=2020, + team="LSU", + return_as_dict=True + ) + print(json_data) + + else: + # Alternatively, if the CFBD API key exists in this python environment, + # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), + # you could just call these functions directly, without setting the API key + # in the script. + print("Using the user's API key suposedly loaded into this python environment for this example.") + + # Get player usage data from the 2020 CFB season. + print("Get player usage data from the 2020 CFB season.") + json_data = get_cfbd_player_usage( + season=2020 + ) + print(json_data) + time.sleep(5) + + # Get player usage data for the + # University of Cincinnati Bearcats Football Team, + # during the 2020 CFB season. + print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.") + json_data = get_cfbd_player_usage( + season=2020, + team="Cincinnati" + ) + print(json_data) + time.sleep(5) + + # Get player usage data from players who + # primarily played running back (RB) in the 2020 CFB season. + print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.") + json_data = get_cfbd_player_usage( + season=2020, + position="RB" + ) + print(json_data) + time.sleep(5) + + # Get player usage data from players who played on + # Big 10 Confrence (B1G) teams during the 2020 CFB Season. + print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.") + json_data = get_cfbd_player_usage( + season=2020, + conference_abv="B1G" + ) + print(json_data) + time.sleep(5) + + # Get player usage data from + # former LSU Tigers quarterback Joe Burrow (player ID #3915511), + # during the 2019 CFB season. + print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.") + json_data = get_cfbd_player_usage( + season=2019, + player_id=3915511 + ) + print(json_data) + time.sleep(5) + + # Get player usage data from + # former LSU Tigers quarterback Joe Burrow (player ID #3915511), + # during the 2019 CFB season, + # but filter out plays that occured in garbage time. + print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.") + json_data = get_cfbd_player_usage( + season=2019, + player_id=3915511, + exclude_garbage_time=True + ) + print(json_data) + time.sleep(5) + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = get_cfbd_player_usage( + season=2020, + team="LSU", + return_as_dict=True + ) + print(json_data) + + + ``` + Returns + ---------- + A pandas `DataFrame` object with player usage data, + or (if `return_as_dict` is set to `True`) + a dictionary object with player usage data. """ - raise NotImplementedError( - 'This function has yet to be implemented by this version.' - ) + + now = datetime.now() + players_df = pd.DataFrame() + row_df = pd.DataFrame() + url = "https://api.collegefootballdata.com/player/usage" + + ######################################################################################################################################################################################################## + + if api_key != None: + real_api_key = api_key + del api_key + else: + real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) + + if real_api_key == "tigersAreAwsome": + raise ValueError( + "You actually need to change `cfbd_key` to your CFBD API key.") + elif "Bearer " in real_api_key: + pass + elif "Bearer" in real_api_key: + real_api_key = real_api_key.replace('Bearer', 'Bearer ') + else: + real_api_key = "Bearer " + real_api_key + + if season == None: + # This should never happen without user tampering, but if it does, + # we need to raise an error, because the CFBD API will refuse this call without a valid season. + raise SystemError( + "I don't know how, I don't know why, but you managed to call this function while `season` was `None` (NULL)," + + " and the function got to this point in the code." + + "\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 + 1): + raise ValueError(f"`season` cannot be greater than {season}.") + elif season < 1869: + raise ValueError(f"`season` cannot be less than 1869.") + + gt_str = "" + if exclude_garbage_time == True: + gt_str = "true" + elif exclude_garbage_time == False: + gt_str = "false" + + # URL builder + ######################################################################################################################################################################################################## + + url += f"?year={season}" + + if team != None: + url += f"&team={team}" + + if conference_abv != None: + url += f"&conference={conference_abv}" + + if position != None: + url += f"&position={position}" + + if player_id != None: + url += f"&playerId={player_id}" + print() + if exclude_garbage_time != None: + url += f"&excludeGarbageTime={gt_str}" + + headers = { + 'Authorization': f'{real_api_key}', + 'accept': 'application/json' + } + + response = requests.get(url, headers=headers) + + if response.status_code == 200: + pass + elif response.status_code == 401: + raise ConnectionRefusedError( + f'Could not connect. The connection was refused.\nHTTP Status Code 401.' + ) + else: + raise ConnectionError( + f'Could not connect.\nHTTP Status code {response.status_code}' + ) + + json_data = response.json() + + if return_as_dict == True: + return json_data + + for player in tqdm(json_data): + row_df = pd.DataFrame( + {"season": season}, + index=[0] + ) + row_df['player_id'] = player['id'] + row_df['player_name'] = player['name'] + row_df['player_position'] = player['position'] + row_df['team'] = player['team'] + row_df['conference'] = player['conference'] + row_df['player_usage_overall'] = player['usage']['overall'] + row_df['player_usage_passing'] = player['usage']['pass'] + row_df['player_usage_rushing'] = player['usage']['rush'] + row_df['player_usage_1st_downs'] = player['usage']['firstDown'] + row_df['player_usage_2nd_downs'] = player['usage']['secondDown'] + row_df['player_usage_3rd_downs'] = player['usage']['thirdDown'] + row_df['player_usage_standard_downs'] = player['usage']['standardDowns'] + row_df['player_usage_pasing_downs'] = player['usage']['passingDowns'] + + players_df = pd.concat([players_df, row_df], ignore_index=True) + del row_df + + return players_df def get_cfbd_returning_production( - season: int, api_key: str = None, api_key_dir: str = None, + season: int = None, team: str = None, + # `season` or `team` must be specified. conference_abv: str = None, - return_as_dict: bool = False): """ + Get data from the CFBD API + on how much returning production a team has going into a CFB season. + + Parameters + ---------- + + `api_key` (str, optional): + Semi-optional argument. + If `api_key` is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If `api_key` is not null, this function will automatically assume that the + inputted `api_key` is a valid CFBD API key. + + `api_key_dir` (str, optional): + Optional argument. + If `api_key` is set to am empty string, this variable is ignored. + If `api_key_dir` is null, and `api_key` is null, + this function will try to find a CFBD API key file in this user's home directory. + If `api_key_dir` is set to a string, and `api_key` is null, + this function will assume that `api_key_dir` is a directory, + and will try to find a CFBD API key file in that directory. + + `season` (int, optional): + Semi-optional argument. + Specifies the season you want team PPA data from. + You MUST set `season` or `team` to a non-null value for + this function to work. If you don't, a `ValueError()` + will be raised. + + `team` (str, optional): + Semi-ptional argument. + If you only want team PPA data for a specific team, + set `team` to the name of the team you want team PPA data from. + You MUST set `season` or `team` to a non-null value for + this function to work. If you don't, a `ValueError()` + will be raised. + + `conference_abv` (str, optional): + Optional argument. + If you only want team PPA data from games + involving teams from a specific confrence, + set `conference_abv` to the abbreviation + of the conference you want team PPA data from. + For a list of confrences, + use the `cfbd_json_py.conferences.get_cfbd_conference_info()` + function. + + `return_as_dict` (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas `DataFrame` object, + set `return_as_dict` to `True`. + + Usage + ---------- + ``` + import time + + from cfbd_json_py.players import get_cfbd_returning_production + + + cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. + + if cfbd_key != "tigersAreAwsome": + print("Using the user's API key declared in this script for this example.") + + # Get returning production for teams who competed in the 2020 CFB season. + print("Get returning production for teams who competed in the 2020 CFB season.") + json_data = get_cfbd_returning_production( + api_key=cfbd_key, + season=2020 + ) + print(json_data) + time.sleep(5) + + # Get historical returning production for the Ohio Bobcats Football Team. + print("Get historical returning production for the Ohio Bobcats Football Team.") + json_data = get_cfbd_returning_production( + api_key=cfbd_key, + team="Ohio" + ) + print(json_data) + time.sleep(5) + + # Get returning production for the 2019 LSU Tigers. + print("Get returning production for the 2019 LSU Tigers.") + json_data = get_cfbd_returning_production( + api_key=cfbd_key, + season=2019, + team="LSU" + ) + print(json_data) + time.sleep(5) + + # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference. + print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.") + json_data = get_cfbd_returning_production( + api_key=cfbd_key, + team="Maryland", + conference_abv="B1G" + ) + print(json_data) + time.sleep(5) + + # Get returning production . + print("Get returning production for the 2019 LSU Tigers.") + json_data = get_cfbd_returning_production( + api_key=cfbd_key, + season=2019, + team="LSU" + ) + print(json_data) + time.sleep(5) + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = get_cfbd_returning_production( + api_key=cfbd_key, + season=2020, + team="LSU", + return_as_dict=True + ) + print(json_data) + + else: + # Alternatively, if the CFBD API key exists in this python environment, + # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), + # you could just call these functions directly, without setting the API key + # in the script. + print("Using the user's API key suposedly loaded into this python environment for this example.") + + # Get returning production for teams who competed in the 2020 CFB season. + print("Get returning production for teams who competed in the 2020 CFB season.") + json_data = get_cfbd_returning_production( + season=2020 + ) + print(json_data) + time.sleep(5) + + # Get historical returning production for the Ohio Bobcats Football Team. + print("Get historical returning production for the Ohio Bobcats Football Team.") + json_data = get_cfbd_returning_production( + team="Ohio" + ) + print(json_data) + time.sleep(5) + + # Get returning production for the 2019 LSU Tigers. + print("Get returning production for the 2019 LSU Tigers.") + json_data = get_cfbd_returning_production( + season=2019, + team="LSU" + ) + print(json_data) + time.sleep(5) + + # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference. + print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.") + json_data = get_cfbd_returning_production( + team="Maryland", + conference_abv="B1G" + ) + print(json_data) + time.sleep(5) + + # Get returning production . + print("Get returning production for the 2019 LSU Tigers.") + json_data = get_cfbd_returning_production( + season=2019, + team="LSU" + ) + print(json_data) + time.sleep(5) + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = get_cfbd_returning_production( + season=2020, + team="LSU", + return_as_dict=True + ) + print(json_data) + + ``` + Returns + ---------- + A pandas `DataFrame` object with returning production data, + or (if `return_as_dict` is set to `True`) + a dictionary object with returning production data. """ - raise NotImplementedError( - 'This function has yet to be implemented by this version.' - ) + now = datetime.now() + team_df = pd.DataFrame() + row_df = pd.DataFrame() + url = "https://api.collegefootballdata.com/player/returning" + + ######################################################################################################################################################################################################## + + if api_key != None: + real_api_key = api_key + del api_key + else: + real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) + + if real_api_key == "tigersAreAwsome": + raise ValueError( + "You actually need to change `cfbd_key` to your CFBD API key.") + elif "Bearer " in real_api_key: + pass + elif "Bearer" in real_api_key: + real_api_key = real_api_key.replace('Bearer', 'Bearer ') + else: + real_api_key = "Bearer " + real_api_key + + if season == None and team == None: + raise ValueError( + "To use this function, `season` and/or `team` must be set to a " + + "non-null variable." + ) + + if season == None: + # Rare, but in this endpoint, + # you don't need to input the season. + pass + 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.") + + # URL Builder + ######################################################################################################################################################################################################## + url_elements = 0 + + if season != None and url_elements == 0: + url += f"?year={season}" + url_elements += 1 + elif season != None: + url += f"&year={season}" + url_elements += 1 + + if team != None and url_elements == 0: + url += f"?team={team}" + url_elements += 1 + elif team != None: + url += f"&team={team}" + url_elements += 1 + + if conference_abv != None and url_elements == 0: + url += f"?conference={conference_abv}" + url_elements += 1 + elif conference_abv != None: + url += f"&conference={conference_abv}" + url_elements += 1 + + headers = { + 'Authorization': f'{real_api_key}', + 'accept': 'application/json' + } + + response = requests.get(url, headers=headers) + + if response.status_code == 200: + pass + elif response.status_code == 401: + raise ConnectionRefusedError( + f'Could not connect. The connection was refused.\nHTTP Status Code 401.' + ) + else: + raise ConnectionError( + f'Could not connect.\nHTTP Status code {response.status_code}' + ) + + json_data = response.json() + + if return_as_dict == True: + return json_data + + for team in tqdm(json_data): + t_season = team['season'] + t_conference = team['conference'] + t_name = team['team'] + + row_df = pd.DataFrame( + { + "season": t_season, + "team_name": t_name, + "team_conference": t_conference + }, + index=[0] + ) + row_df['total_ppa'] = team['totalPPA'] + row_df['total_ppa_passing'] = team['totalPassingPPA'] + row_df['total_ppa_rushing'] = team['totalRushingPPA'] + row_df['total_ppa_receiving'] = team['totalReceivingPPA'] + row_df['percent_ppa'] = team['percentPPA'] + row_df['percent_ppa_passing'] = team['percentPassingPPA'] + row_df['percent_ppa_rushing'] = team['percentRushingPPA'] + row_df['percent_ppa_receiving'] = team['percentReceivingPPA'] + row_df['usage'] = team['usage'] + row_df['passing_usage'] = team['passingUsage'] + row_df['rushing_usage'] = team['rushingUsage'] + row_df['receiving_usage'] = team['receivingUsage'] + + team_df = pd.concat([team_df, row_df], ignore_index=True) + + del row_df + del t_season, t_conference, t_name + + return team_df def get_cfbd_player_season_stats( @@ -64,27 +1042,1497 @@ def get_cfbd_player_season_stats( conference_abv: str = None, start_week: int = None, end_week: int = None, - season_type: str = 'regular', # "regular", "postseason", or "both" + season_type: str = "both", # "regular", "postseason", or "both" stat_category: str = None, - return_as_dict: bool = False): """ + Get player season stats, or the stats of players in a specific timeframe, from the CFBD API. + + Parameters + ---------- + `season` (int, mandatory): + Required argument. + Specifies the season you want CFB player season stats from. + This must be specified, otherwise this package, and by extension + the CFBD API, will not accept the request to get CFB player season stats. + + `api_key` (str, optional): + Semi-optional argument. + If `api_key` is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If `api_key` is not null, this function will automatically assume that the + inputted `api_key` is a valid CFBD API key. + + `api_key_dir` (str, optional): + Optional argument. + If `api_key` is set to am empty string, this variable is ignored. + If `api_key_dir` is null, and `api_key` is null, + this function will try to find a CFBD API key file in this user's home directory. + If `api_key_dir` is set to a string, and `api_key` is null, + this function will assume that `api_key_dir` is a directory, + and will try to find a CFBD API key file in that directory. + + `team` (str, optional): + Optional argument. + If you only want CFB player season stats for a team, + regardless if they are the home/away team, + set `team` to the name of the team you want CFB player season stats from. + + `conference_abv` (str, optional): + Optional argument. + If you only want player season stats from games + involving teams a specific confrence, + set `conference_abv` to the abbreviation + of the conference you want stats from. + + `start_week` (int, semi-optional): + Optional argument. + If you only want player stats for a range of weeks, + set `start_week` and `end_week` to + the range of weeks you want season-level data for. + + `end_week` (int, semi-optional): + Optional argument. + If you only want player stats for a range of weeks, + set `start_week` and `end_week` to + the range of weeks you want season-level data for. + + **NOTE**: If the following conditions are `True`, a `ValueError()` + will be raised when calling this function: + - `start_week < 0` + - `end_week < 0` + - `start_week != None and end_week == None` (will be changed in a future version) + - `start_week == None and end_week != None` (will be changed in a future version) + - `end_week < start_week` + - `end_week = start_week` + + `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, + set `season_type` to "postseason". + If you want ***both*** regular and postseason stats, set `season_type = "both"`. + If `season_type` is set to anything but "regular", "postseason", or "both", + a `ValueError()` will be raised. + + `stat_category` (str, optional): + Optional argument. + If only want stats for a specific stat category, + set this variable to that category. + + Valid inputs are: + - `passing` + - `rushing` + - `receiving` + - `fumbles` + - `defensive` + - `interceptions` + - `punting` + - `kicking` + - `kickReturns` + - `puntReturns` + + `return_as_dict` (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas `DataFrame` object, + set `return_as_dict` to `True`. + + Usage + ---------- + ``` + import time + + from cfbd_json_py.players import get_cfbd_player_season_stats + + + cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. + + if cfbd_key != "tigersAreAwsome": + print("Using the user's API key declared in this script for this example.") + + # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season. + print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2020, + team="Ohio" + ) + print(json_data) + time.sleep(5) + + # Get player season stats for teams who competed in + # the Southeastern Confrence (SEC) in the 2023 CFB season. + print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2020, + conference_abv="SEC" + ) + print(json_data) + time.sleep(5) + + # Get player season stats for teams who competed in + # the Southeastern Confrence (SEC) in the 2023 CFB season, + # but only between weeks 1 and 5. + print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2020, + conference_abv="SEC", + start_week=1, + end_week=5 + ) + print(json_data) + time.sleep(5) + + + # Get player season stats for the 2020 CFB season. + print("Get player season stats for the 2020 CFB season.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2020 + ) + print(json_data) + time.sleep(5) + + + # Get player season stats for + # the Ohio Bobcats Football team in the 2022 CFB season, + # but only use regular season games when calculating season stats. + print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2022, + team="Ohio", + season_type="regular" + ) + print(json_data) + time.sleep(5) + + # Get passing stats for teams who competed in + # the Southeastern Confrence (SEC) in the 2023 CFB season. + print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2020, + conference_abv="SEC", + stat_category="passing" + ) + print(json_data) + time.sleep(5) + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = get_cfbd_player_season_stats( + api_key=cfbd_key, + season=2020, + team="LSU", + stat_category="kicking", + return_as_dict=True + ) + print(json_data) + + else: + # Alternatively, if the CFBD API key exists in this python environment, + # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), + # you could just call these functions directly, without setting the API key + # in the script. + print("Using the user's API key suposedly loaded into this python environment for this example.") + + # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season. + print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.") + json_data = get_cfbd_player_season_stats( + season=2020, + team="Ohio" + ) + print(json_data) + time.sleep(5) + + # Get player season stats for teams who competed in + # the Southeastern Confrence (SEC) in the 2023 CFB season. + print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.") + json_data = get_cfbd_player_season_stats( + season=2020, + conference_abv="SEC" + ) + print(json_data) + time.sleep(5) + + # Get player season stats for teams who competed in + # the Southeastern Confrence (SEC) in the 2023 CFB season, + # but only between weeks 1 and 5. + print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.") + json_data = get_cfbd_player_season_stats( + season=2020, + conference_abv="SEC", + start_week=1, + end_week=5 + ) + print(json_data) + time.sleep(5) + + + # Get player season stats for the 2020 CFB season. + print("Get player season stats for the 2020 CFB season.") + json_data = get_cfbd_player_season_stats( + season=2020 + ) + print(json_data) + time.sleep(5) + + + # Get player season stats for + # the Ohio Bobcats Football team in the 2022 CFB season, + # but only use regular season games when calculating season stats. + print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.") + json_data = get_cfbd_player_season_stats( + season=2022, + team="Ohio", + season_type="regular" + ) + print(json_data) + time.sleep(5) + + # Get passing stats for teams who competed in + # the Southeastern Confrence (SEC) in the 2023 CFB season. + print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.") + json_data = get_cfbd_player_season_stats( + season=2020, + conference_abv="SEC", + stat_category="passing" + ) + print(json_data) + time.sleep(5) + + # You can also tell this function to just return the API call as + # a Dictionary (read: JSON) object. + print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") + json_data = get_cfbd_player_season_stats( + season=2020, + team="LSU", + stat_category="kicking", + return_as_dict=True + ) + print(json_data) + + + ``` + Returns + ---------- + A pandas `DataFrame` object with a list of players who matched the search string, + or (if `return_as_dict` is set to `True`) + a dictionary object with a list of players who matched the search string. """ - raise NotImplementedError( - 'This function has yet to be implemented by this version.' - ) + + rebuilt_json = {} + stat_columns = [ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # PASS + 'passing_COMP', + 'passing_ATT', + 'passing_COMP%', + 'passing_YDS', + 'passing_AVG', + 'passing_TD', + 'passing_INT', + # RUSH + 'rushing_CAR', + 'rushing_YDS', + 'rushing_AVG', + 'rushing_TD', + 'rushing_LONG', + # REC + 'receiving_REC', + 'receiving_YDS', + 'receiving_AVG', + 'receiving_TD', + 'receiving_LONG', + # FUM + 'fumbles_FUM', + 'fumbles_LOST', + 'fumbles_REC', + # DEFENSE + 'defensive_TOT', + 'defensive_SOLO', + 'defensive_TFL', + 'defensive_QB HUR', + 'defensive_SACKS', + 'defensive_PD', + 'defensive_TD', + # INT + 'interceptions_INT', + 'interceptions_YDS', + 'interceptions_TD', + # PUNT + 'punting_NO', + 'punting_YDS', + 'punting_AVG', + 'punting_TB', + 'punting_In 20', + 'punting_LONG', + # KICK + 'kicking_FGM', + 'kicking_FGA', + 'kicking_FG%', + 'kicking_LONG', + 'kicking_XPM', + 'kicking_XPA', + 'kicking_XP%', + # KR + 'kickReturns_NO', + 'kickReturns_YDS', + 'kickReturns_AVG', + 'kickReturns_TD', + 'kickReturns_LONG', + # PR + 'puntReturns_NO', + 'puntReturns_YDS', + 'puntReturns_AVG', + 'puntReturns_TD', + 'puntReturns_LONG' + ] + + now = datetime.now() + url = "https://api.collegefootballdata.com/stats/player/season" + + final_df = pd.DataFrame() + + if api_key != None: + real_api_key = api_key + del api_key + else: + real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) + + if real_api_key == "tigersAreAwsome": + raise ValueError( + "You actually need to change `cfbd_key` to your CFBD API key.") + elif "Bearer " in real_api_key: + pass + elif "Bearer" in real_api_key: + real_api_key = real_api_key.replace('Bearer', 'Bearer ') + else: + real_api_key = "Bearer " + real_api_key + + if season == None: + # This should never happen without user tampering, but if it does, + # we need to raise an error, because the CFBD API will refuse this call without a valid season. + raise SystemError( + "I don't know how, I don't know why, " + + "but you managed to call this function while `season` was `None` (NULL)," + + " and the function got to this point in the code." + + "\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 + 1): + raise ValueError(f"`season` cannot be greater than {season}.") + elif season < 1869: + raise ValueError(f"`season` cannot be less than 1869.") + + if season_type != "regular" and season_type != "postseason" and season_type != "both": + raise ValueError( + "`season_type` must be set to either \"regular\" or " + + "\"postseason\" for this function to work." + ) + + filter_by_stat_category = False + + if stat_category == None: + pass + elif stat_category == "passing": + filter_by_stat_category = True + elif stat_category == "rushing": + filter_by_stat_category = True + elif stat_category == "receiving": + filter_by_stat_category = True + elif stat_category == "fumbles": + filter_by_stat_category = True + elif stat_category == "passing": + filter_by_stat_category = True + elif stat_category == "defensive": + filter_by_stat_category = True + elif stat_category == "interceptions": + filter_by_stat_category = True + elif stat_category == "punting": + filter_by_stat_category = True + elif stat_category == "kicking": + filter_by_stat_category = True + elif stat_category == "kickReturns": + filter_by_stat_category = True + elif stat_category == "puntReturns": + filter_by_stat_category = True + else: + raise ValueError( + "Invalid input for `stat_category`." + + "\nValid inputs are:" + + """ + - `passing` + - `rushing` + - `receiving` + - `fumbles` + - `defensive` + - `interceptions` + - `punting` + - `kicking` + - `kickReturns` + - `puntReturns` + """ + ) + + if start_week != None and end_week != None: + if start_week > end_week: + raise ValueError( + "`start_week` cannot be greater than `end_week`." + ) + elif start_week == end_week: + raise ValueError( + "`start_week` cannot be equal to `end_week`." + + "\n Use `cfbd_json_py.games.get_cfbd_player_game_stats()` instead " + + "if you want player stats for a specific week in ." + ) + elif start_week < 0: + raise ValueError( + "`start_week` cannot be less than 0." + ) + elif end_week < 0: + raise ValueError( + "`end_week` cannot be less than 0." + ) + # + # elif start_week != None and end_week == None: + # raise ValueError( + # "At this time, if you want to get season stats for a range of weeks " + + # "`start_week` and `end_week` must be set to valid integers," + + # " and not just `start_week`." + # ) + # elif start_week == None and end_week != None: + # raise ValueError( + # "At this time, if you want to get season stats for a range of weeks " + + # "`start_week` and `end_week` must be set to valid integers," + + # " and not just `end_week`." + # ) + + if filter_by_stat_category == True: + pass + + # URL builder + ######################################################################################################################################################################################################## + + # Required by the API + url += f"?year={season}" + + if team != None: + url += f"&team={team}" + + if conference_abv != None: + url += f"&conference={conference_abv}" + + if season_type != None: + url += f"&seasonType={season_type}" + + if stat_category != None: + url += f"&category={stat_category}" + + if start_week != None: + url += f"&startWeek={start_week}" + + if end_week != None: + url += f"&endWeek={end_week}" + + headers = { + 'Authorization': f'{real_api_key}', + 'accept': 'application/json' + } + + response = requests.get(url, headers=headers) + + if response.status_code == 200: + pass + elif response.status_code == 401: + raise ConnectionRefusedError( + f'Could not connect. The connection was refused.\nHTTP Status Code 401.' + ) + else: + raise ConnectionError( + f'Could not connect.\nHTTP Status code {response.status_code}' + ) + + json_data = response.json() + + if return_as_dict == True: + return json_data + + for player in tqdm(json_data): + player_id = int(player['playerId']) + player_name = player['player'] + team_name = player['team'] + team_confrence = player['conference'] + s_category = player['category'] + s_type = player['statType'] + s_num = player['stat'] + + if rebuilt_json.get(player_id) == None: + rebuilt_json[player_id] = {} + + if s_category == "passing": + if s_type == "COMPLETIONS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['passing_COMP'] = s_num + + elif s_type == "ATT": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['passing_ATT'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['passing_YDS'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['passing_TD'] = s_num + + elif s_type == "INT": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['passing_INT'] = s_num + # we can calculate these two later + elif s_type == "PCT": + pass + + elif s_type == "YPA": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "rushing": + if s_type == "CAR": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['rushing_CAR'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['rushing_YDS'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['rushing_TD'] = s_num + + elif s_type == "LONG": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['rushing_LONG'] = s_num + # we can calculate this later + elif s_type == "YPC": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "receiving": + if s_type == "REC": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['receiving_REC'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['receiving_YDS'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['receiving_TD'] = s_num + + elif s_type == "LONG": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['receiving_LONG'] = s_num + # we can calculate this later + elif s_type == "YPR": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "fumbles": + if s_type == "FUM": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['fumbles_FUM'] = s_num + + elif s_type == "LOST": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['fumbles_LOST'] = s_num + + elif s_type == "REC": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['fumbles_LOST'] = s_num + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "defensive": + if s_type == "TOT": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_TOT'] = s_num + + elif s_type == "SOLO": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_SOLO'] = s_num + + elif s_type == "TFL": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_TFL'] = s_num + + elif s_type == "QB HUR": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_QB HUR'] = s_num + + elif s_type == "SACKS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_SACKS'] = s_num + + elif s_type == "PD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_PD'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['defensive_TD'] = s_num + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "interceptions": + if s_type == "INT": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['interceptions_INT'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['interceptions_YDS'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['interceptions_TD'] = s_num + + elif s_type == "AVG": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "punting": + if s_type == "NO": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['punting_NO'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['punting_YDS'] = s_num + + elif s_type == "TB": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['punting_TB'] = s_num + + elif s_type == "In 20": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['punting_In 20'] = s_num + + elif s_type == "LONG": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['punting_LONG'] = s_num + + elif s_type == "YPP": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "kicking": + if s_type == "FGM": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kicking_FGM'] = s_num + + elif s_type == "FGA": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kicking_FGA'] = s_num + + elif s_type == "LONG": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kicking_LONG'] = s_num + + elif s_type == "XPM": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kicking_XPM'] = s_num + + elif s_type == "XPA": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kicking_XPA'] = s_num + + elif s_type == "PTS": + pass + + elif s_type == "PCT": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "kickReturns": + if s_type == "NO": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kickReturns_NO'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kickReturns_YDS'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kickReturns_TD'] = s_num + + elif s_type == "LONG": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['kickReturns_LONG'] = s_num + # we can calculate this later + elif s_type == "AVG": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + elif s_category == "puntReturns": + if s_type == "NO": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['puntReturns_NO'] = s_num + + elif s_type == "YDS": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['puntReturns_YDS'] = s_num + + elif s_type == "TD": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['puntReturns_TD'] = s_num + + elif s_type == "LONG": + rebuilt_json[player_id]['player_name'] = player_name + rebuilt_json[player_id]['team_name'] = team_name + rebuilt_json[player_id]['team_confrence'] = team_confrence + rebuilt_json[player_id]['puntReturns_LONG'] = s_num + # we can calculate this later + elif s_type == "AVG": + pass + + else: + raise ValueError(f"Unhandled stat type: {s_type}") + + else: + raise ValueError(f"Unhandled stat category: {s_category}") + + del player_id, player_name, team_name, team_confrence,\ + s_category, s_type, s_num + + for key, value in tqdm(rebuilt_json.items()): + # print(key) + + # print(value) + team_name = value['team_name'] + team_confrence = value['team_confrence'] + player_id = key + player_name = value['player_name'] + + row_df = pd.DataFrame( + { + "team_name": team_name, + "team_confrence": team_confrence, + "player_id": player_id, + "player_name": player_name + }, + index=[0] + ) + # Passing + if value.get('passing_COMP') != None: + row_df['passing_COMP'] = value['passing_COMP'] + + if value.get('passing_ATT') != None: + row_df['passing_ATT'] = value['passing_ATT'] + + if value.get('passing_YDS') != None: + row_df['passing_YDS'] = value['passing_YDS'] + + if value.get('passing_TD') != None: + row_df['passing_TD'] = value['passing_TD'] + + if value.get('passing_INT') != None: + row_df['passing_INT'] = value['passing_INT'] + + # Rushing + if value.get('rushing_CAR') != None: + row_df['rushing_CAR'] = value['rushing_CAR'] + + if value.get('rushing_YDS') != None: + row_df['rushing_YDS'] = value['rushing_YDS'] + + if value.get('rushing_AVG') != None: + row_df['rushing_AVG'] = value['rushing_AVG'] + + if value.get('rushing_TD') != None: + row_df['rushing_TD'] = value['rushing_TD'] + + if value.get('rushing_LONG') != None: + row_df['rushing_LONG'] = value['rushing_LONG'] + + # Receiving + if value.get('receiving_REC') != None: + row_df['receiving_REC'] = value['receiving_REC'] + + if value.get('receiving_YDS') != None: + row_df['receiving_YDS'] = value['receiving_YDS'] + + if value.get('receiving_TD') != None: + row_df['receiving_TD'] = value['receiving_TD'] + + if value.get('receiving_LONG') != None: + row_df['receiving_LONG'] = value['receiving_LONG'] + + # Fumbles + if value.get('fumbles_FUM') != None: + row_df['fumbles_FUM'] = value['fumbles_FUM'] + + if value.get('fumbles_LOST') != None: + row_df['fumbles_LOST'] = value['fumbles_LOST'] + + if value.get('fumbles_REC') != None: + row_df['fumbles_REC'] = value['fumbles_REC'] + + # Defense + if value.get('defensive_TOT') != None: + row_df['defensive_TOT'] = value['defensive_TOT'] + + if value.get('defensive_SOLO') != None: + row_df['defensive_SOLO'] = value['defensive_SOLO'] + + if value.get('defensive_TFL') != None: + row_df['defensive_TFL'] = value['defensive_TFL'] + + if value.get('defensive_QB HUR') != None: + row_df['defensive_QB HUR'] = value['defensive_QB HUR'] + + if value.get('defensive_SACKS') != None: + row_df['defensive_SACKS'] = value['defensive_SACKS'] + + if value.get('defensive_PD') != None: + row_df['defensive_PD'] = value['defensive_PD'] + + if value.get('defensive_TD') != None: + row_df['defensive_TD'] = value['defensive_TD'] + + # interceptions + if value.get('interceptions_INT') != None: + row_df['interceptions_INT'] = value['interceptions_INT'] + + if value.get('interceptions_YDS') != None: + row_df['interceptions_YDS'] = value['interceptions_YDS'] + + if value.get('interceptions_TD') != None: + row_df['interceptions_TD'] = value['interceptions_TD'] + + # punting + if value.get('punting_NO') != None: + row_df['punting_NO'] = value['punting_NO'] + + if value.get('punting_YDS') != None: + row_df['punting_YDS'] = value['punting_YDS'] + + if value.get('punting_TB') != None: + row_df['punting_TB'] = value['punting_TB'] + + if value.get('punting_In 20') != None: + row_df['punting_In 20'] = value['punting_In 20'] + + if value.get('punting_LONG') != None: + row_df['punting_LONG'] = value['punting_LONG'] + + # kicking + if value.get('kicking_FGM') != None: + row_df['kicking_FGM'] = value['kicking_FGM'] + + if value.get('kicking_FGA') != None: + row_df['kicking_FGA'] = value['kicking_FGA'] + + if value.get('kicking_LONG') != None: + row_df['kicking_LONG'] = value['kicking_LONG'] + + if value.get('kicking_XPM') != None: + row_df['kicking_XPM'] = value['kicking_XPM'] + + if value.get('kicking_XPA') != None: + row_df['kicking_XPA'] = value['kicking_XPA'] + + # kickReturns + if value.get('kickReturns_NO') != None: + row_df['kickReturns_NO'] = value['kickReturns_NO'] + + if value.get('kickReturns_YDS') != None: + row_df['kickReturns_YDS'] = value['kickReturns_YDS'] + + if value.get('kickReturns_AVG') != None: + row_df['kickReturns_AVG'] = value['kickReturns_AVG'] + + if value.get('kickReturns_TD') != None: + row_df['kickReturns_TD'] = value['kickReturns_TD'] + + if value.get('kickReturns_LONG') != None: + row_df['kickReturns_LONG'] = value['kickReturns_LONG'] + + # puntReturns + if value.get('puntReturns_NO') != None: + row_df['puntReturns_NO'] = value['puntReturns_NO'] + + if value.get('puntReturns_YDS') != None: + row_df['puntReturns_YDS'] = value['puntReturns_YDS'] + + if value.get('puntReturns_AVG') != None: + row_df['puntReturns_AVG'] = value['puntReturns_AVG'] + + if value.get('puntReturns_TD') != None: + row_df['puntReturns_TD'] = value['puntReturns_TD'] + + if value.get('puntReturns_LONG') != None: + row_df['puntReturns_LONG'] = value['puntReturns_LONG'] + + final_df = pd.concat([final_df, row_df], ignore_index=True) + del row_df + + final_df = final_df.fillna(0) + + final_df['season'] = season + + if filter_by_stat_category == False: + final_df = final_df.reindex(columns=stat_columns) + final_df = final_df.astype({ + "passing_COMP": "int", + "passing_ATT": "int", + "rushing_CAR": "int", + "rushing_YDS": "int", + "receiving_REC": "int", + "receiving_YDS": "int", + "punting_NO": "int", + "punting_YDS": "int", + "kicking_FGM": "int", + "kicking_FGA": "int", + "kicking_XPM": "int", + "kicking_XPA": "int", + "kickReturns_NO": "int", + "kickReturns_YDS": "int", + "puntReturns_NO": "int", + "puntReturns_YDS": "int", + + }) + + final_df.loc[ + final_df['passing_ATT'] > 0, 'passing_COMP%'] = final_df['passing_COMP'] / final_df['passing_ATT'] + + final_df.loc[ + final_df['rushing_CAR'] > 0, 'rushing_AVG'] = final_df['rushing_YDS'] / final_df['rushing_CAR'] + + final_df.loc[ + final_df['receiving_REC'] > 0, 'receiving_AVG'] = final_df['receiving_YDS']/final_df['receiving_REC'] + + + final_df.loc[ + final_df['punting_NO'] > 0, 'punting_AVG'] = final_df['punting_YDS']/final_df['punting_NO'] + + final_df.loc[ + final_df['kicking_FGA'] > 0, 'kicking_FG%'] = final_df['kicking_FGM']/final_df['kicking_FGA'] + + final_df.loc[ + final_df['kicking_XPA'] > 0, 'kicking_XP%'] = final_df['kicking_XPM']/final_df['kicking_XPA'] + + final_df.loc[ + final_df['kickReturns_NO'] > 0, 'kickReturns_AVG'] = final_df['kickReturns_YDS']/final_df['kickReturns_NO'] + + final_df.loc[ + final_df['puntReturns_NO'] > 0, 'puntReturns_AVG'] = final_df['puntReturns_YDS']/final_df['puntReturns_NO'] + + + elif filter_by_stat_category == True and stat_category == "passing": + try: + final_df = final_df.astype({ + "passing_COMP": "int", + "passing_ATT": "int", + }) + except: + logging.warning( + "Could not reformat [passing_COMP] and [passing_ATT] into integers." + ) + + final_df.loc[ + final_df['passing_ATT'] >= 1, 'passing_COMP%'] = final_df['passing_COMP'] / final_df['passing_ATT'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # PASS + 'passing_COMP', + 'passing_ATT', + 'passing_YDS', + 'passing_TD', + 'passing_INT', + ]] + + elif filter_by_stat_category == True and stat_category == "rushing": + try: + final_df = final_df.astype({ + "rushing_CAR": "int", + "rushing_YDS": "int", + }) + except: + logging.warning( + "Could not reformat [rushing_CAR] and [rushing_YDS] into integers." + ) + + final_df.loc[ + final_df['rushing_CAR'] >= 1, 'rushing_AVG'] = final_df['rushing_YDS'] / final_df['rushing_CAR'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # RUSH + 'rushing_CAR', + 'rushing_YDS', + 'rushing_AVG', + 'rushing_TD', + 'rushing_LONG', + ]] + + elif filter_by_stat_category == True and stat_category == "receiving": + try: + final_df = final_df.astype({ + "receiving_REC": "int", + "receiving_YDS": "int", + }) + except: + logging.warning( + "Could not reformat [receiving_REC] and [receiving_YDS] into integers." + ) + + final_df.loc[ + final_df['receiving_REC'] > 0, 'receiving_AVG'] = final_df['receiving_YDS']/final_df['receiving_REC'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # REC + 'receiving_REC', + 'receiving_YDS', + 'receiving_AVG', + 'receiving_TD', + 'receiving_LONG' + ]] + + elif filter_by_stat_category == True and stat_category == "fumbles": + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # FUM + 'fumbles_FUM', + 'fumbles_LOST', + 'fumbles_REC' + ]] + + elif filter_by_stat_category == True and stat_category == "defensive": + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # DEFENSE + 'defensive_TOT', + 'defensive_SOLO', + 'defensive_TFL', + 'defensive_QB HUR', + 'defensive_SACKS', + 'defensive_PD', + 'defensive_TD' + ]] + + elif filter_by_stat_category == True and stat_category == "interceptions": + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # INT + 'interceptions_INT', + 'interceptions_YDS', + 'interceptions_TD', + ]] + + elif filter_by_stat_category == True and stat_category == "punting": + try: + final_df = final_df.astype({ + "punting_NO": "int", + "punting_YDS": "int", + }) + except: + logging.warning( + "Could not reformat [punting_YDS] and [punting_NO] into integers." + ) + + final_df.loc[ + final_df['punting_NO'] > 0, 'punting_AVG'] = final_df['punting_YDS']/final_df['punting_NO'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # PUNT + 'punting_NO', + 'punting_YDS', + 'punting_AVG', + 'punting_TB', + 'punting_In 20', + 'punting_LONG' + ]] + + elif filter_by_stat_category == True and stat_category == "kicking": + try: + final_df = final_df.astype({ + "kicking_FGM": "int", + "kicking_FGA": "int", + "kicking_XPM": "int", + "kicking_XPA": "int" + }) + except: + logging.warning( + "Could not reformat the following columns into integers.:"+ + "\n-[kicking_FGM]"+ + "\n-[kicking_FGA]"+ + "\n-[kicking_XPM]"+ + "\n-[kicking_XPA]" + + ) + + final_df.loc[ + final_df['kicking_FGA'] > 0, 'kicking_FG%'] = final_df['kicking_FGM']/final_df['kicking_FGA'] + + final_df.loc[ + final_df['kicking_XPA'] > 0, 'kicking_XP%'] = final_df['kicking_XPM']/final_df['kicking_XPA'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # KICK + 'kicking_FGM', + 'kicking_FGA', + 'kicking_FG%', + 'kicking_LONG', + 'kicking_XPM', + 'kicking_XPA' + 'kicking_XP%', + ]] + + elif filter_by_stat_category == True and stat_category == "kickReturns": + try: + final_df = final_df.astype({ + "kickReturns_NO": "int", + "kickReturns_YDS": "int", + }) + except: + logging.warning( + "Could not reformat [passing_COMP] and [kickReturns_YDS] into integers." + ) + + + final_df.loc[ + final_df['kickReturns_NO'] > 0, 'kickReturns_AVG'] = final_df['kickReturns_YDS']/final_df['kickReturns_NO'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # KR + 'kickReturns_NO', + 'kickReturns_YDS', + 'kickReturns_AVG', + 'kickReturns_TD', + 'kickReturns_LONG' + ]] + + elif filter_by_stat_category == True and stat_category == "puntReturns": + try: + final_df = final_df.astype({ + "puntReturns_NO": "int", + "puntReturns_YDS": "int", + }) + except: + logging.warning( + "Could not reformat [passing_COMP] and [puntReturns_YDS] into integers." + ) + + + final_df.loc[ + final_df['puntReturns_NO'] > 0, 'puntReturns_AVG'] = final_df['puntReturns_YDS']/final_df['puntReturns_NO'] + + final_df = final_df[[ + 'season', + 'team_name', + 'team_confrence', + 'player_id', + 'player_name', + # KR + 'puntReturns_NO', + 'puntReturns_YDS', + 'puntReturns_AVG', + 'puntReturns_TD', + 'puntReturns_LONG' + ]] + + return final_df def get_cfbd_transfer_portal_data( season: int, api_key: str = None, api_key_dir: str = None, - return_as_dict: bool = False): """ + Get player usage data (A.K.A., the percentages for how often a player touched the ball), + for a given season, from the CFBD API. + + Parameters + ---------- + `season` (int, mandatory): + Required argument. + Specifies the season you want CFB transfer portal data from. + This must be specified, otherwise this package, and by extension + the CFBD API, will not accept the request to get CFB transfer portal data stats. + + `api_key` (str, optional): + Semi-optional argument. + If `api_key` is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If `api_key` is not null, this function will automatically assume that the + inputted `api_key` is a valid CFBD API key. + + `api_key_dir` (str, optional): + Optional argument. + If `api_key` is set to am empty string, this variable is ignored. + If `api_key_dir` is null, and `api_key` is null, + this function will try to find a CFBD API key file in this user's home directory. + If `api_key_dir` is set to a string, and `api_key` is null, + this function will assume that `api_key_dir` is a directory, + and will try to find a CFBD API key file in that directory. + + `return_as_dict` (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas `DataFrame` object, + set `return_as_dict` to `True`. + + Usage + ---------- + ``` + ``` + Returns + ---------- + A pandas `DataFrame` object with transfer portal data, + or (if `return_as_dict` is set to `True`) + a dictionary object with transfer portal data. """ - raise NotImplementedError( - 'This function has yet to be implemented by this version.' - ) + now = datetime.now() + url = "https://api.collegefootballdata.com/player/portal" + + portal_df = pd.DataFrame() + row_df = pd.DataFrame() + + if api_key != None: + real_api_key = api_key + del api_key + else: + real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) + + if real_api_key == "tigersAreAwsome": + raise ValueError( + "You actually need to change `cfbd_key` to your CFBD API key.") + elif "Bearer " in real_api_key: + pass + elif "Bearer" in real_api_key: + real_api_key = real_api_key.replace('Bearer', 'Bearer ') + else: + real_api_key = "Bearer " + real_api_key + + if season == None: + # This should never happen without user tampering, but if it does, + # we need to raise an error, because the CFBD API will refuse this call without a valid season. + raise SystemError( + "I don't know how, I don't know why, " + + "but you managed to call this function while `season` was `None` (NULL)," + + " and the function got to this point in the code." + + "\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 + 1): + raise ValueError(f"`season` cannot be greater than {season}.") + elif season < 2017: + raise ValueError(f"Transfer portal wasn't really a thing in {season}.") + + # URL builder + ######################################################################################################################################################################################################## + + ## required by API + url += f"?year={season}" + + headers = { + 'Authorization': f'{real_api_key}', + 'accept': 'application/json' + } + + + response = requests.get(url, headers=headers) + + if response.status_code == 200: + pass + elif response.status_code == 401: + raise ConnectionRefusedError( + f'Could not connect. The connection was refused.\nHTTP Status Code 401.' + ) + else: + raise ConnectionError( + f'Could not connect.\nHTTP Status code {response.status_code}' + ) + + json_data = response.json() + + if return_as_dict == True: + return json_data + + for player in tqdm(json_data): + row_df = pd.DataFrame({"season":season},index=[0]) + row_df['first_name'] = player['firstName'] + row_df['last_name'] = player['lastName'] + row_df['position'] = player['position'] + row_df['origin_team'] = player['origin'] + row_df['destination_team'] = player['destination'] + row_df['transferDate'] = player['transferDate'] + row_df['player_rating'] = player['rating'] + row_df['player_stars'] = player['stars'] + row_df['player_eligibility'] = player['eligibility'] + portal_df = pd.concat([portal_df,row_df],ignore_index=True) + + del row_df + + return portal_df \ No newline at end of file diff --git a/docs/cfbd_json_py/drives.html b/docs/cfbd_json_py/drives.html index 2f6db74..626138f 100644 --- a/docs/cfbd_json_py/drives.html +++ b/docs/cfbd_json_py/drives.html @@ -55,7 +55,7 @@

  1# Creation Date: 08/30/2023 01:13 EDT
-  2# Last Updated Date: 10/23/2023 04:09 PM EDT
+  2# Last Updated Date: 11/04/2023 02:55 PM EDT
   3# Author: Joseph Armstrong (armstrongjoseph08@gmail.com)
   4# File Name: drives.py
   5# Purpose: Houses functions pertaining to CFB drive data within the CFBD API.
@@ -473,7 +473,7 @@ 

417 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 418 "https://github.com/armstjc/cfbd-json-py/issues" 419 ) -420 elif season > now.year: +420 elif season > (now.year + 1): 421 raise ValueError(f"`season` cannot be greater than {season}.") 422 elif season < 1869: 423 raise ValueError(f"`season` cannot be less than 1869.") @@ -1015,7 +1015,7 @@

418 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 419 "https://github.com/armstjc/cfbd-json-py/issues" 420 ) -421 elif season > now.year: +421 elif season > (now.year + 1): 422 raise ValueError(f"`season` cannot be greater than {season}.") 423 elif season < 1869: 424 raise ValueError(f"`season` cannot be less than 1869.") diff --git a/docs/cfbd_json_py/games.html b/docs/cfbd_json_py/games.html index 87f91b5..502322a 100644 --- a/docs/cfbd_json_py/games.html +++ b/docs/cfbd_json_py/games.html @@ -76,7 +76,7 @@

   1# Creation Date: 08/30/2023 01:13 EDT
-   2# Last Updated Date: 10/23/2023 04:09 PM EDT
+   2# Last Updated Date: 11/04/2023 02:55 PM EDT
    3# Author: Joseph Armstrong (armstrongjoseph08@gmail.com)
    4# File Name: games.py
    5# Purpose: Houses functions pertaining to CFB game data within the CFBD API.
@@ -444,7 +444,7 @@ 

367 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 368 "https://github.com/armstjc/cfbd-json-py/issues" 369 ) - 370 elif season > now.year: + 370 elif season > (now.year + 1): 371 raise ValueError(f"`season` cannot be greater than {season}.") 372 elif season < 1869: 373 raise ValueError(f"`season` cannot be less than 1869.") @@ -1009,7 +1009,7 @@

932 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 933 "https://github.com/armstjc/cfbd-json-py/issues" 934 ) - 935 elif season > now.year: + 935 elif season > (now.year + 1): 936 raise ValueError(f"`season` cannot be greater than {season}.") 937 elif season < 1869: 938 raise ValueError(f"`season` cannot be less than 1869.") @@ -1389,7 +1389,7 @@

1312 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 1313 "https://github.com/armstjc/cfbd-json-py/issues" 1314 ) -1315 elif season > now.year: +1315 elif season > (now.year + 1): 1316 raise ValueError(f"`season` cannot be greater than {season}.") 1317 elif season < 1869: 1318 raise ValueError(f"`season` cannot be less than 1869.") @@ -1514,9 +1514,9 @@

1437 ---------- 1438 `season` (int, mandatory): 1439 Required argument. -1440 Specifies the season you want CFB media information from. +1440 Specifies the season you want CFB player game stats from. 1441 This must be specified, otherwise this package, and by extension -1442 the CFBD API, will not accept the request to get CFB media information. +1442 the CFBD API, will not accept the request to get CFB player game stats. 1443 1444 `api_key` (str, optional): 1445 Semi-optional argument. @@ -1537,7 +1537,7 @@

1460 `season_type` (str, semi-optional): 1461 Semi-optional argument. 1462 By defualt, this will be set to "regular", for the CFB regular season. -1463 If you want CFB media information for non-regular season games, +1463 If you want CFB player game stats for non-regular season games, 1464 set `season_type` to "postseason". 1465 If `season_type` is set to anything but "regular" or "postseason", 1466 a `ValueError()` will be raised. @@ -1548,20 +1548,20 @@

1471 `week` (int, optional): 1472 Optional argument. 1473 If `week` is set to an integer, this function will attempt -1474 to load CFB media information from games in that season, and in that week. +1474 to load CFB player game stats from games in that season, and in that week. 1475 1476 `team` (str, optional): 1477 Optional argument. -1478 If you only want CFB media information for a team, +1478 If you only want CFB player game stats for a team, 1479 regardless if they are the home/away team, -1480 set `team` to the name of the team you want CFB media information from. +1480 set `team` to the name of the team you want CFB player game stats from. 1481 1482 `conference_abv` (str, optional): 1483 Optional argument. -1484 If you only want media information from games +1484 If you only want player game stats from games 1485 involving teams a specific confrence, 1486 set `conference_abv` to the abbreviation -1487 of the conference you want game information from. +1487 of the conference you want stats from. 1488 1489 `stat_category` (str, optional): 1490 Optional argument. @@ -1770,1849 +1770,1861 @@

1693 row_df = pd.DataFrame() 1694 url = "https://api.collegefootballdata.com/games/players" 1695 stat_columns = [ -1696 'game_id', -1697 'team_name', -1698 'team_confrence', -1699 'player_id', -1700 'player_name', -1701 'home_away', -1702 # PASS -1703 'passing_C/ATT', -1704 'passing_COMP', -1705 'passing_ATT', -1706 'passing_YDS', -1707 'passing_AVG', -1708 'passing_TD', -1709 'passing_INT', -1710 'passing_QBR', -1711 # RUSH -1712 'rushing_CAR', -1713 'rushing_YDS', -1714 'rushing_AVG', -1715 'rushing_TD', -1716 'rushing_LONG', -1717 # REC -1718 'receiving_REC', -1719 'receiving_YDS', -1720 'receiving_AVG', -1721 'receiving_TD', -1722 'receiving_LONG', -1723 # FUM -1724 'fumbles_FUM', -1725 'fumbles_LOST', -1726 'fumbles_REC', -1727 # DEFENSE -1728 'defensive_TOT', -1729 'defensive_SOLO', -1730 'defensive_TFL', -1731 'defensive_QB HUR', -1732 'defensive_SACKS', -1733 'defensive_PD', -1734 'defensive_TD', -1735 # INT -1736 'interceptions_INT', -1737 'interceptions_YDS', -1738 'interceptions_TD', -1739 # PUNT -1740 'punting_NO', -1741 'punting_YDS', -1742 'punting_AVG', -1743 'punting_TB', -1744 'punting_In 20', -1745 'punting_LONG', -1746 # KICK -1747 'kicking_FG', -1748 'kicking_FGM', -1749 'kicking_FGA', -1750 'kicking_PCT', -1751 'kicking_LONG', -1752 'kicking_XP', -1753 'kicking_XPM', -1754 'kicking_XPA', -1755 'kicking_PTS', -1756 # KR -1757 'kickReturns_NO', -1758 'kickReturns_YDS', -1759 'kickReturns_AVG', -1760 'kickReturns_TD', -1761 'kickReturns_LONG', -1762 # PR -1763 'puntReturns_NO', -1764 'puntReturns_YDS', -1765 'puntReturns_AVG', -1766 'puntReturns_TD', -1767 'puntReturns_LONG' -1768 ] -1769 -1770 ######################################################################################################################################################################################################## -1771 -1772 if api_key != None: -1773 real_api_key = api_key -1774 del api_key -1775 else: -1776 real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) -1777 -1778 if real_api_key == "tigersAreAwsome": -1779 raise ValueError( -1780 "You actually need to change `cfbd_key` to your CFBD API key.") -1781 elif "Bearer " in real_api_key: -1782 pass -1783 elif "Bearer" in real_api_key: -1784 real_api_key = real_api_key.replace('Bearer', 'Bearer ') -1785 else: -1786 real_api_key = "Bearer " + real_api_key -1787 -1788 if season == None: -1789 # This should never happen without user tampering, but if it does, -1790 # we need to raise an error, because the CFBD API will refuse this call without a valid season. -1791 raise SystemError( -1792 "I don't know how, I don't know why, " + -1793 "but you managed to call this function while `season` was `None` (NULL)," + -1794 " and the function got to this point in the code." + -1795 "\nIf you have a GitHub account, " + -1796 "please raise an issue on this python package's GitHub page:\n" + -1797 "https://github.com/armstjc/cfbd-json-py/issues" -1798 ) -1799 elif season > now.year: -1800 raise ValueError(f"`season` cannot be greater than {season}.") -1801 elif season < 1869: -1802 raise ValueError(f"`season` cannot be less than 1869.") -1803 -1804 if season_type != "regular" and season_type != "postseason": -1805 raise ValueError( -1806 "`season_type` must be set to either \"regular\" or " + -1807 "\"postseason\" for this function to work." -1808 ) -1809 -1810 # `week`, `team`, and/or `conference` -1811 # must be not null for this function to work. -1812 -1813 if week == None and team == None and conference_abv == None and game_id == None: -1814 raise ValueError( -1815 "To use `get_cfbd_player_game_stats()`," + -1816 " `week`, `team`, and/or `conference_abv` need to be set to a non-null value." -1817 ) -1818 -1819 filter_by_stat_category = False -1820 -1821 if stat_category == None: -1822 pass -1823 elif stat_category == "passing": -1824 filter_by_stat_category = True -1825 elif stat_category == "rushing": -1826 filter_by_stat_category = True -1827 elif stat_category == "receiving": -1828 filter_by_stat_category = True -1829 elif stat_category == "fumbles": -1830 filter_by_stat_category = True -1831 elif stat_category == "passing": -1832 filter_by_stat_category = True -1833 elif stat_category == "defensive": -1834 filter_by_stat_category = True -1835 elif stat_category == "interceptions": -1836 filter_by_stat_category = True -1837 elif stat_category == "punting": -1838 filter_by_stat_category = True -1839 elif stat_category == "kicking": -1840 filter_by_stat_category = True -1841 elif stat_category == "kickReturns": -1842 filter_by_stat_category = True -1843 elif stat_category == "puntReturns": -1844 filter_by_stat_category = True -1845 else: -1846 raise ValueError( -1847 "Invalid input for `stat_category`." + -1848 "\nValid inputs are:" + -1849 """ -1850 - `passing` -1851 - `rushing` -1852 - `receiving` -1853 - `fumbles` -1854 - `defensive` -1855 - `interceptions` -1856 - `punting` -1857 - `kicking` -1858 - `kickReturns` -1859 - `puntReturns` -1860 """ -1861 ) -1862 -1863 # URL builder -1864 ######################################################################################################################################################################################################## -1865 -1866 # Required by the API -1867 url += f"?year={season}" -1868 -1869 if game_id != None: -1870 url += f"&gameId={game_id}" -1871 -1872 if stat_category != None: -1873 url += f"&category={stat_category}" -1874 -1875 if week != None or team != None or conference_abv != None: -1876 logging.warning( -1877 "When calling `cfbd_json_py.games.get_cfbd_player_game_stats()`, " + -1878 "and setting `game_id` to a non-null value, " + -1879 "only `season`, `stat_category`, and `game_id` are considered " + -1880 "when calling the CFBD API." -1881 ) -1882 else: -1883 if season_type != None: -1884 url += f"&seasonType={season_type}" -1885 -1886 if week != None: -1887 url += f"&week={week}" -1888 -1889 if team != None: -1890 url += f"&team={team}" -1891 -1892 if conference_abv != None: -1893 url += f"&conference={conference_abv}" -1894 -1895 headers = { -1896 'Authorization': f'{real_api_key}', -1897 'accept': 'application/json' -1898 } -1899 -1900 response = requests.get(url, headers=headers) -1901 -1902 -1903 if response.status_code == 200: -1904 pass -1905 elif response.status_code == 401: -1906 raise ConnectionRefusedError( -1907 f'Could not connect. The connection was refused.\nHTTP Status Code 401.' -1908 ) -1909 else: -1910 raise ConnectionError( -1911 f'Could not connect.\nHTTP Status code {response.status_code}' -1912 ) -1913 -1914 json_data = response.json() -1915 -1916 if return_as_dict == True: -1917 return json_data -1918 -1919 for game in tqdm(json_data): -1920 game_id = game['id'] -1921 -1922 for team in game['teams']: -1923 team_name = team['school'] -1924 team_confrence = team['conference'] -1925 home_away = team['homeAway'] -1926 -1927 for s_category in team['categories']: -1928 if s_category['name'] == "passing": -1929 for stat in s_category['types']: -1930 -1931 if stat['name'] == "C/ATT": # passing_C/ATT -1932 -1933 for i in stat['athletes']: -1934 player_id = int(i['id']) -1935 player_name = i['name'] -1936 player_stat = i['stat'] -1937 -1938 if rebuilt_json.get(player_id) == None: -1939 rebuilt_json[player_id] = {} -1940 -1941 rebuilt_json[player_id]['game_id'] = game_id -1942 rebuilt_json[player_id]['team_name'] = team_name -1943 rebuilt_json[player_id]['team_confrence'] = team_confrence -1944 rebuilt_json[player_id]['player_id'] = player_id -1945 rebuilt_json[player_id]['player_name'] = player_name -1946 rebuilt_json[player_id]['home_away'] = home_away -1947 rebuilt_json[player_id]['passing_C/ATT'] = player_stat -1948 -1949 elif stat['name'] == "YDS": # passing_YDS -1950 -1951 for i in stat['athletes']: -1952 player_id = int(i['id']) -1953 player_name = i['name'] -1954 player_stat = int(i['stat']) -1955 -1956 if rebuilt_json.get(player_id) == None: -1957 rebuilt_json[player_id] = {} -1958 -1959 rebuilt_json[player_id]['game_id'] = game_id -1960 rebuilt_json[player_id]['team_name'] = team_name -1961 rebuilt_json[player_id]['team_confrence'] = team_confrence -1962 rebuilt_json[player_id]['player_id'] = player_id -1963 rebuilt_json[player_id]['player_name'] = player_name -1964 rebuilt_json[player_id]['home_away'] = home_away -1965 rebuilt_json[player_id]['passing_YDS'] = player_stat -1966 -1967 elif stat['name'] == "AVG": # passing_AVG -1968 for i in stat['athletes']: -1969 player_id = int(i['id']) -1970 player_name = i['name'] -1971 player_stat = float(i['stat']) -1972 -1973 if rebuilt_json.get(player_id) == None: -1974 rebuilt_json[player_id] = {} -1975 -1976 rebuilt_json[player_id]['game_id'] = game_id -1977 rebuilt_json[player_id]['team_name'] = team_name -1978 rebuilt_json[player_id]['team_confrence'] = team_confrence -1979 rebuilt_json[player_id]['player_id'] = player_id -1980 rebuilt_json[player_id]['player_name'] = player_name -1981 rebuilt_json[player_id]['home_away'] = home_away -1982 rebuilt_json[player_id]['passing_AVG'] = player_stat -1983 -1984 elif stat['name'] == "TD": # passing_TD -1985 -1986 for i in stat['athletes']: -1987 player_id = int(i['id']) -1988 player_name = i['name'] -1989 player_stat = int(i['stat']) -1990 -1991 if rebuilt_json.get(player_id) == None: -1992 rebuilt_json[player_id] = {} -1993 -1994 rebuilt_json[player_id]['game_id'] = game_id -1995 rebuilt_json[player_id]['team_name'] = team_name -1996 rebuilt_json[player_id]['team_confrence'] = team_confrence -1997 rebuilt_json[player_id]['player_id'] = player_id -1998 rebuilt_json[player_id]['player_name'] = player_name -1999 rebuilt_json[player_id]['home_away'] = home_away -2000 rebuilt_json[player_id]['passing_TD'] = player_stat -2001 -2002 elif stat['name'] == "INT": # passing_INT -2003 -2004 for i in stat['athletes']: -2005 player_id = int(i['id']) -2006 player_name = i['name'] -2007 player_stat = int(i['stat']) -2008 -2009 if rebuilt_json.get(player_id) == None: -2010 rebuilt_json[player_id] = {} -2011 -2012 rebuilt_json[player_id]['game_id'] = game_id -2013 rebuilt_json[player_id]['team_name'] = team_name -2014 rebuilt_json[player_id]['team_confrence'] = team_confrence -2015 rebuilt_json[player_id]['player_id'] = player_id -2016 rebuilt_json[player_id]['player_name'] = player_name -2017 rebuilt_json[player_id]['home_away'] = home_away -2018 rebuilt_json[player_id]['passing_INT'] = player_stat -2019 -2020 elif stat['name'] == "QBR": # passing_QBR -2021 for i in stat['athletes']: -2022 player_id = int(i['id']) -2023 player_name = i['name'] -2024 try: -2025 player_stat = float(i['stat']) -2026 except: -2027 player_stat = None -2028 -2029 if rebuilt_json.get(player_id) == None: -2030 rebuilt_json[player_id] = {} -2031 -2032 rebuilt_json[player_id]['game_id'] = game_id -2033 rebuilt_json[player_id]['team_name'] = team_name -2034 rebuilt_json[player_id]['team_confrence'] = team_confrence -2035 rebuilt_json[player_id]['player_id'] = player_id -2036 rebuilt_json[player_id]['player_name'] = player_name -2037 rebuilt_json[player_id]['home_away'] = home_away -2038 rebuilt_json[player_id]['passing_QBR'] = player_stat -2039 -2040 else: -2041 raise IndexError( -2042 f"Unhandled stat: \t{stat['name']}") -2043 # passing_df = pd.DataFrame(s_category['types']) -2044 elif s_category['name'] == "rushing": -2045 for stat in s_category['types']: -2046 if stat['name'] == "CAR": # rushing_CAR -2047 for i in stat['athletes']: -2048 player_id = int(i['id']) -2049 player_name = i['name'] -2050 player_stat = int(i['stat']) -2051 -2052 if rebuilt_json.get(player_id) == None: -2053 rebuilt_json[player_id] = {} -2054 -2055 rebuilt_json[player_id]['game_id'] = game_id -2056 rebuilt_json[player_id]['team_name'] = team_name -2057 rebuilt_json[player_id]['team_confrence'] = team_confrence -2058 rebuilt_json[player_id]['player_id'] = player_id -2059 rebuilt_json[player_id]['player_name'] = player_name -2060 rebuilt_json[player_id]['home_away'] = home_away -2061 rebuilt_json[player_id]['rushing_CAR'] = player_stat -2062 -2063 elif stat['name'] == "YDS": # rushing_YDS -2064 for i in stat['athletes']: -2065 player_id = int(i['id']) -2066 player_name = i['name'] -2067 player_stat = int(i['stat']) -2068 -2069 if rebuilt_json.get(player_id) == None: -2070 rebuilt_json[player_id] = {} -2071 -2072 rebuilt_json[player_id]['game_id'] = game_id -2073 rebuilt_json[player_id]['team_name'] = team_name -2074 rebuilt_json[player_id]['team_confrence'] = team_confrence -2075 rebuilt_json[player_id]['player_id'] = player_id -2076 rebuilt_json[player_id]['player_name'] = player_name -2077 rebuilt_json[player_id]['home_away'] = home_away -2078 rebuilt_json[player_id]['rushing_YDS'] = player_stat -2079 -2080 elif stat['name'] == "AVG": # rushing_AVG -2081 for i in stat['athletes']: -2082 player_id = int(i['id']) -2083 player_name = i['name'] -2084 player_stat = float(i['stat']) -2085 -2086 if rebuilt_json.get(player_id) == None: -2087 rebuilt_json[player_id] = {} -2088 -2089 rebuilt_json[player_id]['game_id'] = game_id -2090 rebuilt_json[player_id]['team_name'] = team_name -2091 rebuilt_json[player_id]['team_confrence'] = team_confrence -2092 rebuilt_json[player_id]['player_id'] = player_id -2093 rebuilt_json[player_id]['player_name'] = player_name -2094 rebuilt_json[player_id]['home_away'] = home_away -2095 rebuilt_json[player_id]['rushing_AVG'] = player_stat -2096 -2097 elif stat['name'] == "TD": # rushing_TD -2098 for i in stat['athletes']: -2099 player_id = int(i['id']) -2100 player_name = i['name'] -2101 player_stat = int(i['stat']) -2102 -2103 if rebuilt_json.get(player_id) == None: -2104 rebuilt_json[player_id] = {} -2105 -2106 rebuilt_json[player_id]['game_id'] = game_id -2107 rebuilt_json[player_id]['team_name'] = team_name -2108 rebuilt_json[player_id]['team_confrence'] = team_confrence -2109 rebuilt_json[player_id]['player_id'] = player_id -2110 rebuilt_json[player_id]['player_name'] = player_name -2111 rebuilt_json[player_id]['home_away'] = home_away -2112 rebuilt_json[player_id]['rushing_TD'] = player_stat -2113 -2114 elif stat['name'] == "LONG": # rushing_LONG -2115 for i in stat['athletes']: -2116 player_id = int(i['id']) -2117 player_name = i['name'] -2118 player_stat = int(i['stat']) -2119 -2120 if rebuilt_json.get(player_id) == None: -2121 rebuilt_json[player_id] = {} -2122 -2123 rebuilt_json[player_id]['game_id'] = game_id -2124 rebuilt_json[player_id]['team_name'] = team_name -2125 rebuilt_json[player_id]['team_confrence'] = team_confrence -2126 rebuilt_json[player_id]['player_id'] = player_id -2127 rebuilt_json[player_id]['player_name'] = player_name -2128 rebuilt_json[player_id]['home_away'] = home_away -2129 rebuilt_json[player_id]['rushing_LONG'] = player_stat -2130 -2131 else: -2132 raise IndexError( -2133 f"Unhandled stat: \t{stat['name']}") -2134 -2135 elif s_category['name'] == "receiving": -2136 for stat in s_category['types']: -2137 if stat['name'] == "REC": # receiving_REC -2138 for i in stat['athletes']: -2139 player_id = int(i['id']) -2140 player_name = i['name'] -2141 player_stat = int(i['stat']) -2142 -2143 if rebuilt_json.get(player_id) == None: -2144 rebuilt_json[player_id] = {} -2145 -2146 rebuilt_json[player_id]['game_id'] = game_id -2147 rebuilt_json[player_id]['team_name'] = team_name -2148 rebuilt_json[player_id]['team_confrence'] = team_confrence -2149 rebuilt_json[player_id]['player_id'] = player_id -2150 rebuilt_json[player_id]['player_name'] = player_name -2151 rebuilt_json[player_id]['home_away'] = home_away -2152 rebuilt_json[player_id]['receiving_REC'] = player_stat -2153 -2154 elif stat['name'] == "YDS": # receiving_YDS -2155 for i in stat['athletes']: -2156 player_id = int(i['id']) -2157 player_name = i['name'] -2158 player_stat = int(i['stat']) -2159 -2160 if rebuilt_json.get(player_id) == None: -2161 rebuilt_json[player_id] = {} -2162 -2163 rebuilt_json[player_id]['game_id'] = game_id -2164 rebuilt_json[player_id]['team_name'] = team_name -2165 rebuilt_json[player_id]['team_confrence'] = team_confrence -2166 rebuilt_json[player_id]['player_id'] = player_id -2167 rebuilt_json[player_id]['player_name'] = player_name -2168 rebuilt_json[player_id]['home_away'] = home_away -2169 rebuilt_json[player_id]['receiving_YDS'] = player_stat -2170 -2171 elif stat['name'] == "AVG": # receiving_AVG -2172 for i in stat['athletes']: -2173 player_id = int(i['id']) -2174 player_name = i['name'] -2175 player_stat = float(i['stat']) -2176 -2177 if rebuilt_json.get(player_id) == None: -2178 rebuilt_json[player_id] = {} -2179 -2180 rebuilt_json[player_id]['game_id'] = game_id -2181 rebuilt_json[player_id]['team_name'] = team_name -2182 rebuilt_json[player_id]['team_confrence'] = team_confrence -2183 rebuilt_json[player_id]['player_id'] = player_id -2184 rebuilt_json[player_id]['player_name'] = player_name -2185 rebuilt_json[player_id]['home_away'] = home_away -2186 rebuilt_json[player_id]['receiving_AVG'] = player_stat -2187 -2188 elif stat['name'] == "TD": # receiving_TD -2189 for i in stat['athletes']: -2190 player_id = int(i['id']) -2191 player_name = i['name'] -2192 player_stat = int(i['stat']) -2193 -2194 if rebuilt_json.get(player_id) == None: -2195 rebuilt_json[player_id] = {} -2196 -2197 rebuilt_json[player_id]['game_id'] = game_id -2198 rebuilt_json[player_id]['team_name'] = team_name -2199 rebuilt_json[player_id]['team_confrence'] = team_confrence -2200 rebuilt_json[player_id]['player_id'] = player_id -2201 rebuilt_json[player_id]['player_name'] = player_name -2202 rebuilt_json[player_id]['home_away'] = home_away -2203 rebuilt_json[player_id]['receiving_TD'] = player_stat -2204 -2205 elif stat['name'] == "LONG": # receiving_LONG -2206 for i in stat['athletes']: -2207 player_id = int(i['id']) -2208 player_name = i['name'] -2209 player_stat = int(i['stat']) -2210 -2211 if rebuilt_json.get(player_id) == None: -2212 rebuilt_json[player_id] = {} -2213 -2214 rebuilt_json[player_id]['game_id'] = game_id -2215 rebuilt_json[player_id]['team_name'] = team_name -2216 rebuilt_json[player_id]['team_confrence'] = team_confrence -2217 rebuilt_json[player_id]['player_id'] = player_id -2218 rebuilt_json[player_id]['player_name'] = player_name -2219 rebuilt_json[player_id]['home_away'] = home_away -2220 rebuilt_json[player_id]['receiving_LONG'] = player_stat -2221 -2222 else: -2223 raise IndexError( -2224 f"Unhandled stat: \t{stat['name']}") -2225 -2226 elif s_category['name'] == "fumbles": -2227 for stat in s_category['types']: -2228 if stat['name'] == "FUM": # fumbles_FUM -2229 for i in stat['athletes']: -2230 player_id = int(i['id']) -2231 player_name = i['name'] -2232 player_stat = int(i['stat']) -2233 -2234 if rebuilt_json.get(player_id) == None: -2235 rebuilt_json[player_id] = {} -2236 -2237 rebuilt_json[player_id]['game_id'] = game_id -2238 rebuilt_json[player_id]['team_name'] = team_name -2239 rebuilt_json[player_id]['team_confrence'] = team_confrence -2240 rebuilt_json[player_id]['player_id'] = player_id -2241 rebuilt_json[player_id]['player_name'] = player_name -2242 rebuilt_json[player_id]['home_away'] = home_away -2243 rebuilt_json[player_id]['fumbles_FUM'] = player_stat -2244 -2245 elif stat['name'] == "LOST": # fumbles_LOST -2246 for i in stat['athletes']: -2247 player_id = int(i['id']) -2248 player_name = i['name'] -2249 player_stat = int(i['stat']) -2250 -2251 if rebuilt_json.get(player_id) == None: -2252 rebuilt_json[player_id] = {} -2253 -2254 rebuilt_json[player_id]['game_id'] = game_id -2255 rebuilt_json[player_id]['team_name'] = team_name -2256 rebuilt_json[player_id]['team_confrence'] = team_confrence -2257 rebuilt_json[player_id]['player_id'] = player_id -2258 rebuilt_json[player_id]['player_name'] = player_name -2259 rebuilt_json[player_id]['home_away'] = home_away -2260 rebuilt_json[player_id]['fumbles_LOST'] = player_stat -2261 -2262 elif stat['name'] == "REC": # fumbles_REC -2263 for i in stat['athletes']: -2264 player_id = int(i['id']) -2265 player_name = i['name'] -2266 player_stat = int(i['stat']) -2267 -2268 if rebuilt_json.get(player_id) == None: -2269 rebuilt_json[player_id] = {} -2270 -2271 rebuilt_json[player_id]['game_id'] = game_id -2272 rebuilt_json[player_id]['team_name'] = team_name -2273 rebuilt_json[player_id]['team_confrence'] = team_confrence -2274 rebuilt_json[player_id]['player_id'] = player_id -2275 rebuilt_json[player_id]['player_name'] = player_name -2276 rebuilt_json[player_id]['home_away'] = home_away -2277 rebuilt_json[player_id]['fumbles_REC'] = player_stat -2278 -2279 else: -2280 raise IndexError( -2281 f"Unhandled stat: \t{stat['name']}") -2282 -2283 elif s_category['name'] == "defensive": -2284 for stat in s_category['types']: -2285 if stat['name'] == "TOT": # defensive_TOT -2286 for i in stat['athletes']: -2287 player_id = int(i['id']) -2288 player_name = i['name'] -2289 player_stat = int(i['stat']) -2290 -2291 if rebuilt_json.get(player_id) == None: -2292 rebuilt_json[player_id] = {} -2293 -2294 rebuilt_json[player_id]['game_id'] = game_id -2295 rebuilt_json[player_id]['team_name'] = team_name -2296 rebuilt_json[player_id]['team_confrence'] = team_confrence -2297 rebuilt_json[player_id]['player_id'] = player_id -2298 rebuilt_json[player_id]['player_name'] = player_name -2299 rebuilt_json[player_id]['home_away'] = home_away -2300 rebuilt_json[player_id]['defensive_TOT'] = player_stat -2301 -2302 elif stat['name'] == "SOLO": # defensive_SOLO -2303 for i in stat['athletes']: -2304 player_id = int(i['id']) -2305 player_name = i['name'] -2306 player_stat = int(i['stat']) -2307 -2308 if rebuilt_json.get(player_id) == None: -2309 rebuilt_json[player_id] = {} -2310 -2311 rebuilt_json[player_id]['game_id'] = game_id -2312 rebuilt_json[player_id]['team_name'] = team_name -2313 rebuilt_json[player_id]['team_confrence'] = team_confrence -2314 rebuilt_json[player_id]['player_id'] = player_id -2315 rebuilt_json[player_id]['player_name'] = player_name -2316 rebuilt_json[player_id]['home_away'] = home_away -2317 rebuilt_json[player_id]['defensive_SOLO'] = player_stat -2318 -2319 elif stat['name'] == "TFL": # defensive_TFL -2320 for i in stat['athletes']: -2321 player_id = int(i['id']) -2322 player_name = i['name'] -2323 player_stat = float(i['stat']) -2324 -2325 if rebuilt_json.get(player_id) == None: -2326 rebuilt_json[player_id] = {} -2327 -2328 rebuilt_json[player_id]['game_id'] = game_id -2329 rebuilt_json[player_id]['team_name'] = team_name -2330 rebuilt_json[player_id]['team_confrence'] = team_confrence -2331 rebuilt_json[player_id]['player_id'] = player_id -2332 rebuilt_json[player_id]['player_name'] = player_name -2333 rebuilt_json[player_id]['home_away'] = home_away -2334 rebuilt_json[player_id]['defensive_TFL'] = player_stat -2335 -2336 elif stat['name'] == "QB HUR": # defensive_QB HUR -2337 for i in stat['athletes']: -2338 player_id = int(i['id']) -2339 player_name = i['name'] -2340 player_stat = int(i['stat']) -2341 -2342 if rebuilt_json.get(player_id) == None: -2343 rebuilt_json[player_id] = {} -2344 -2345 rebuilt_json[player_id]['game_id'] = game_id -2346 rebuilt_json[player_id]['team_name'] = team_name -2347 rebuilt_json[player_id]['team_confrence'] = team_confrence -2348 rebuilt_json[player_id]['player_id'] = player_id -2349 rebuilt_json[player_id]['player_name'] = player_name -2350 rebuilt_json[player_id]['home_away'] = home_away -2351 rebuilt_json[player_id]['defensive_QB HUR'] = player_stat -2352 -2353 elif stat['name'] == "SACKS": # defensive_SACKS -2354 for i in stat['athletes']: -2355 player_id = int(i['id']) -2356 player_name = i['name'] -2357 player_stat = float(i['stat']) -2358 -2359 if rebuilt_json.get(player_id) == None: -2360 rebuilt_json[player_id] = {} -2361 -2362 rebuilt_json[player_id]['game_id'] = game_id -2363 rebuilt_json[player_id]['team_name'] = team_name -2364 rebuilt_json[player_id]['team_confrence'] = team_confrence -2365 rebuilt_json[player_id]['player_id'] = player_id -2366 rebuilt_json[player_id]['player_name'] = player_name -2367 rebuilt_json[player_id]['home_away'] = home_away -2368 rebuilt_json[player_id]['defensive_SACKS'] = player_stat -2369 -2370 elif stat['name'] == "PD": # defensive_PD -2371 for i in stat['athletes']: -2372 player_id = int(i['id']) -2373 player_name = i['name'] -2374 player_stat = int(i['stat']) -2375 -2376 if rebuilt_json.get(player_id) == None: -2377 rebuilt_json[player_id] = {} -2378 -2379 rebuilt_json[player_id]['game_id'] = game_id -2380 rebuilt_json[player_id]['team_name'] = team_name -2381 rebuilt_json[player_id]['team_confrence'] = team_confrence -2382 rebuilt_json[player_id]['player_id'] = player_id -2383 rebuilt_json[player_id]['player_name'] = player_name -2384 rebuilt_json[player_id]['home_away'] = home_away -2385 rebuilt_json[player_id]['defensive_PD'] = player_stat -2386 -2387 elif stat['name'] == "TD": # defensive_TD -2388 for i in stat['athletes']: -2389 player_id = int(i['id']) -2390 player_name = i['name'] -2391 player_stat = int(i['stat']) -2392 -2393 if rebuilt_json.get(player_id) == None: -2394 rebuilt_json[player_id] = {} -2395 -2396 rebuilt_json[player_id]['game_id'] = game_id -2397 rebuilt_json[player_id]['team_name'] = team_name -2398 rebuilt_json[player_id]['team_confrence'] = team_confrence -2399 rebuilt_json[player_id]['player_id'] = player_id -2400 rebuilt_json[player_id]['player_name'] = player_name -2401 rebuilt_json[player_id]['home_away'] = home_away -2402 rebuilt_json[player_id]['defensive_TD'] = player_stat -2403 -2404 else: -2405 raise IndexError( -2406 f"Unhandled stat: \t{stat['name']}") -2407 -2408 elif s_category['name'] == "interceptions": -2409 for stat in s_category['types']: -2410 if stat['name'] == "INT": # interceptions_INT -2411 for i in stat['athletes']: -2412 player_id = int(i['id']) -2413 player_name = i['name'] -2414 player_stat = int(i['stat']) -2415 -2416 if rebuilt_json.get(player_id) == None: -2417 rebuilt_json[player_id] = {} -2418 -2419 rebuilt_json[player_id]['game_id'] = game_id -2420 rebuilt_json[player_id]['team_name'] = team_name -2421 rebuilt_json[player_id]['team_confrence'] = team_confrence -2422 rebuilt_json[player_id]['player_id'] = player_id -2423 rebuilt_json[player_id]['player_name'] = player_name -2424 rebuilt_json[player_id]['home_away'] = home_away -2425 rebuilt_json[player_id]['interceptions_INT'] = player_stat -2426 -2427 elif stat['name'] == "YDS": # interceptions_YDS -2428 for i in stat['athletes']: -2429 player_id = int(i['id']) -2430 player_name = i['name'] -2431 player_stat = int(i['stat']) -2432 -2433 if rebuilt_json.get(player_id) == None: -2434 rebuilt_json[player_id] = {} -2435 -2436 rebuilt_json[player_id]['game_id'] = game_id -2437 rebuilt_json[player_id]['team_name'] = team_name -2438 rebuilt_json[player_id]['team_confrence'] = team_confrence -2439 rebuilt_json[player_id]['player_id'] = player_id -2440 rebuilt_json[player_id]['player_name'] = player_name -2441 rebuilt_json[player_id]['home_away'] = home_away -2442 rebuilt_json[player_id]['interceptions_YDS'] = player_stat -2443 -2444 elif stat['name'] == "TD": # interceptions_TD -2445 for i in stat['athletes']: -2446 player_id = int(i['id']) -2447 player_name = i['name'] -2448 player_stat = int(i['stat']) -2449 -2450 if rebuilt_json.get(player_id) == None: -2451 rebuilt_json[player_id] = {} -2452 -2453 rebuilt_json[player_id]['game_id'] = game_id -2454 rebuilt_json[player_id]['team_name'] = team_name -2455 rebuilt_json[player_id]['team_confrence'] = team_confrence -2456 rebuilt_json[player_id]['player_id'] = player_id -2457 rebuilt_json[player_id]['player_name'] = player_name -2458 rebuilt_json[player_id]['home_away'] = home_away -2459 rebuilt_json[player_id]['interceptions_TD'] = player_stat -2460 -2461 else: -2462 raise IndexError( -2463 f"Unhandled stat: \t{stat['name']}") -2464 -2465 elif s_category['name'] == "punting": -2466 for stat in s_category['types']: -2467 if stat['name'] == "NO": # punting_NO -2468 for i in stat['athletes']: -2469 player_id = int(i['id']) -2470 player_name = i['name'] -2471 player_stat = int(i['stat']) -2472 -2473 if rebuilt_json.get(player_id) == None: -2474 rebuilt_json[player_id] = {} -2475 -2476 rebuilt_json[player_id]['game_id'] = game_id -2477 rebuilt_json[player_id]['team_name'] = team_name -2478 rebuilt_json[player_id]['team_confrence'] = team_confrence -2479 rebuilt_json[player_id]['player_id'] = player_id -2480 rebuilt_json[player_id]['player_name'] = player_name -2481 rebuilt_json[player_id]['home_away'] = home_away -2482 rebuilt_json[player_id]['punting_NO'] = player_stat -2483 -2484 elif stat['name'] == "YDS": # punting_YDS -2485 for i in stat['athletes']: -2486 player_id = int(i['id']) -2487 player_name = i['name'] -2488 player_stat = int(i['stat']) -2489 -2490 if rebuilt_json.get(player_id) == None: -2491 rebuilt_json[player_id] = {} -2492 -2493 rebuilt_json[player_id]['game_id'] = game_id -2494 rebuilt_json[player_id]['team_name'] = team_name -2495 rebuilt_json[player_id]['team_confrence'] = team_confrence -2496 rebuilt_json[player_id]['player_id'] = player_id -2497 rebuilt_json[player_id]['player_name'] = player_name -2498 rebuilt_json[player_id]['home_away'] = home_away -2499 rebuilt_json[player_id]['punting_YDS'] = player_stat -2500 -2501 elif stat['name'] == "AVG": # punting_AVG -2502 for i in stat['athletes']: -2503 player_id = int(i['id']) -2504 player_name = i['name'] -2505 player_stat = float(i['stat']) -2506 -2507 if rebuilt_json.get(player_id) == None: -2508 rebuilt_json[player_id] = {} -2509 -2510 rebuilt_json[player_id]['game_id'] = game_id -2511 rebuilt_json[player_id]['team_name'] = team_name -2512 rebuilt_json[player_id]['team_confrence'] = team_confrence -2513 rebuilt_json[player_id]['player_id'] = player_id -2514 rebuilt_json[player_id]['player_name'] = player_name -2515 rebuilt_json[player_id]['home_away'] = home_away -2516 rebuilt_json[player_id]['punting_AVG'] = player_stat -2517 -2518 elif stat['name'] == "TB": # punting_TB -2519 for i in stat['athletes']: -2520 player_id = int(i['id']) -2521 player_name = i['name'] -2522 player_stat = int(i['stat']) -2523 -2524 if rebuilt_json.get(player_id) == None: -2525 rebuilt_json[player_id] = {} -2526 -2527 rebuilt_json[player_id]['game_id'] = game_id -2528 rebuilt_json[player_id]['team_name'] = team_name -2529 rebuilt_json[player_id]['team_confrence'] = team_confrence -2530 rebuilt_json[player_id]['player_id'] = player_id -2531 rebuilt_json[player_id]['player_name'] = player_name -2532 rebuilt_json[player_id]['home_away'] = home_away -2533 rebuilt_json[player_id]['punting_TB'] = player_stat -2534 -2535 elif stat['name'] == "In 20": # punting_In 20 -2536 for i in stat['athletes']: -2537 player_id = int(i['id']) -2538 player_name = i['name'] -2539 player_stat = int(i['stat']) -2540 -2541 if rebuilt_json.get(player_id) == None: -2542 rebuilt_json[player_id] = {} -2543 -2544 rebuilt_json[player_id]['game_id'] = game_id -2545 rebuilt_json[player_id]['team_name'] = team_name -2546 rebuilt_json[player_id]['team_confrence'] = team_confrence -2547 rebuilt_json[player_id]['player_id'] = player_id -2548 rebuilt_json[player_id]['player_name'] = player_name -2549 rebuilt_json[player_id]['home_away'] = home_away -2550 rebuilt_json[player_id]['punting_In 20'] = player_stat -2551 -2552 elif stat['name'] == "LONG": # punting_LONG -2553 for i in stat['athletes']: -2554 player_id = int(i['id']) -2555 player_name = i['name'] -2556 player_stat = int(i['stat']) -2557 -2558 if rebuilt_json.get(player_id) == None: -2559 rebuilt_json[player_id] = {} -2560 -2561 rebuilt_json[player_id]['game_id'] = game_id -2562 rebuilt_json[player_id]['team_name'] = team_name -2563 rebuilt_json[player_id]['team_confrence'] = team_confrence -2564 rebuilt_json[player_id]['player_id'] = player_id -2565 rebuilt_json[player_id]['player_name'] = player_name -2566 rebuilt_json[player_id]['home_away'] = home_away -2567 rebuilt_json[player_id]['punting_LONG'] = player_stat -2568 -2569 else: -2570 raise IndexError( -2571 f"Unhandled stat: \t{stat['name']}") -2572 -2573 elif s_category['name'] == "kicking": -2574 for stat in s_category['types']: -2575 if stat['name'] == "FG": # kicking_FG -2576 for i in stat['athletes']: -2577 player_id = int(i['id']) -2578 player_name = i['name'] -2579 player_stat = i['stat'] -2580 -2581 if rebuilt_json.get(player_id) == None: -2582 rebuilt_json[player_id] = {} -2583 -2584 rebuilt_json[player_id]['game_id'] = game_id -2585 rebuilt_json[player_id]['team_name'] = team_name -2586 rebuilt_json[player_id]['team_confrence'] = team_confrence -2587 rebuilt_json[player_id]['player_id'] = player_id -2588 rebuilt_json[player_id]['player_name'] = player_name -2589 rebuilt_json[player_id]['home_away'] = home_away -2590 rebuilt_json[player_id]['kicking_FG'] = player_stat -2591 -2592 elif stat['name'] == "TOT": # kicking_FG, special case -2593 for i in stat['athletes']: -2594 player_id = int(i['id']) -2595 player_name = i['name'] -2596 player_stat = i['stat'] -2597 -2598 if rebuilt_json.get(player_id) == None: -2599 rebuilt_json[player_id] = {} -2600 -2601 rebuilt_json[player_id]['game_id'] = game_id -2602 rebuilt_json[player_id]['team_name'] = team_name -2603 rebuilt_json[player_id]['team_confrence'] = team_confrence -2604 rebuilt_json[player_id]['player_id'] = player_id -2605 rebuilt_json[player_id]['player_name'] = player_name -2606 rebuilt_json[player_id]['home_away'] = home_away -2607 rebuilt_json[player_id]['kicking_FG'] = player_stat -2608 -2609 elif stat['name'] == "PCT": # kicking_PCT -2610 for i in stat['athletes']: -2611 player_id = int(i['id']) -2612 player_name = i['name'] -2613 player_stat = float(i['stat']) -2614 -2615 if rebuilt_json.get(player_id) == None: -2616 rebuilt_json[player_id] = {} -2617 -2618 rebuilt_json[player_id]['game_id'] = game_id -2619 rebuilt_json[player_id]['team_name'] = team_name -2620 rebuilt_json[player_id]['team_confrence'] = team_confrence -2621 rebuilt_json[player_id]['player_id'] = player_id -2622 rebuilt_json[player_id]['player_name'] = player_name -2623 rebuilt_json[player_id]['home_away'] = home_away -2624 rebuilt_json[player_id]['kicking_PCT'] = player_stat -2625 -2626 elif stat['name'] == "LONG": # kicking_LONG -2627 for i in stat['athletes']: -2628 player_id = int(i['id']) -2629 player_name = i['name'] -2630 player_stat = int(i['stat']) -2631 -2632 if rebuilt_json.get(player_id) == None: -2633 rebuilt_json[player_id] = {} -2634 -2635 rebuilt_json[player_id]['game_id'] = game_id -2636 rebuilt_json[player_id]['team_name'] = team_name -2637 rebuilt_json[player_id]['team_confrence'] = team_confrence -2638 rebuilt_json[player_id]['player_id'] = player_id -2639 rebuilt_json[player_id]['player_name'] = player_name -2640 rebuilt_json[player_id]['home_away'] = home_away -2641 rebuilt_json[player_id]['kicking_LONG'] = player_stat -2642 -2643 elif stat['name'] == "XP": # kicking_XP -2644 for i in stat['athletes']: -2645 player_id = int(i['id']) -2646 player_name = i['name'] -2647 player_stat = i['stat'] -2648 -2649 if rebuilt_json.get(player_id) == None: -2650 rebuilt_json[player_id] = {} -2651 -2652 rebuilt_json[player_id]['game_id'] = game_id -2653 rebuilt_json[player_id]['team_name'] = team_name -2654 rebuilt_json[player_id]['team_confrence'] = team_confrence -2655 rebuilt_json[player_id]['player_id'] = player_id -2656 rebuilt_json[player_id]['player_name'] = player_name -2657 rebuilt_json[player_id]['home_away'] = home_away -2658 rebuilt_json[player_id]['kicking_XP'] = player_stat -2659 -2660 elif stat['name'] == "PTS": # kicking_PTS -2661 for i in stat['athletes']: -2662 player_id = int(i['id']) -2663 player_name = i['name'] -2664 player_stat = int(i['stat']) -2665 -2666 if rebuilt_json.get(player_id) == None: -2667 rebuilt_json[player_id] = {} -2668 -2669 rebuilt_json[player_id]['game_id'] = game_id -2670 rebuilt_json[player_id]['team_name'] = team_name -2671 rebuilt_json[player_id]['team_confrence'] = team_confrence -2672 rebuilt_json[player_id]['player_id'] = player_id -2673 rebuilt_json[player_id]['player_name'] = player_name -2674 rebuilt_json[player_id]['home_away'] = home_away -2675 rebuilt_json[player_id]['kicking_PTS'] = player_stat -2676 -2677 else: -2678 raise IndexError( -2679 f"Unhandled stat: \t{stat['name']}") -2680 -2681 elif s_category['name'] == "kickReturns": -2682 for stat in s_category['types']: -2683 if stat['name'] == "NO": # kickReturns_NO -2684 for i in stat['athletes']: -2685 player_id = int(i['id']) -2686 player_name = i['name'] -2687 player_stat = int(i['stat']) -2688 -2689 if rebuilt_json.get(player_id) == None: -2690 rebuilt_json[player_id] = {} -2691 -2692 rebuilt_json[player_id]['game_id'] = game_id -2693 rebuilt_json[player_id]['team_name'] = team_name -2694 rebuilt_json[player_id]['team_confrence'] = team_confrence -2695 rebuilt_json[player_id]['player_id'] = player_id -2696 rebuilt_json[player_id]['player_name'] = player_name -2697 rebuilt_json[player_id]['home_away'] = home_away -2698 rebuilt_json[player_id]['kickReturns_NO'] = player_stat -2699 -2700 elif stat['name'] == "YDS": # kickReturns_YDS -2701 for i in stat['athletes']: -2702 player_id = int(i['id']) -2703 player_name = i['name'] -2704 player_stat = int(i['stat']) -2705 -2706 if rebuilt_json.get(player_id) == None: -2707 rebuilt_json[player_id] = {} -2708 -2709 rebuilt_json[player_id]['game_id'] = game_id -2710 rebuilt_json[player_id]['team_name'] = team_name -2711 rebuilt_json[player_id]['team_confrence'] = team_confrence -2712 rebuilt_json[player_id]['player_id'] = player_id -2713 rebuilt_json[player_id]['player_name'] = player_name -2714 rebuilt_json[player_id]['home_away'] = home_away -2715 rebuilt_json[player_id]['kickReturns_YDS'] = player_stat -2716 -2717 elif stat['name'] == "AVG": # kickReturns_AVG -2718 for i in stat['athletes']: -2719 player_id = int(i['id']) -2720 player_name = i['name'] -2721 player_stat = float(i['stat']) -2722 -2723 if rebuilt_json.get(player_id) == None: -2724 rebuilt_json[player_id] = {} -2725 -2726 rebuilt_json[player_id]['game_id'] = game_id -2727 rebuilt_json[player_id]['team_name'] = team_name -2728 rebuilt_json[player_id]['team_confrence'] = team_confrence -2729 rebuilt_json[player_id]['player_id'] = player_id -2730 rebuilt_json[player_id]['player_name'] = player_name -2731 rebuilt_json[player_id]['home_away'] = home_away -2732 rebuilt_json[player_id]['kickReturns_AVG'] = player_stat -2733 -2734 elif stat['name'] == "TD": # kickReturns_TD -2735 for i in stat['athletes']: -2736 player_id = int(i['id']) -2737 player_name = i['name'] -2738 player_stat = int(i['stat']) -2739 -2740 if rebuilt_json.get(player_id) == None: -2741 rebuilt_json[player_id] = {} -2742 -2743 rebuilt_json[player_id]['game_id'] = game_id -2744 rebuilt_json[player_id]['team_name'] = team_name -2745 rebuilt_json[player_id]['team_confrence'] = team_confrence -2746 rebuilt_json[player_id]['player_id'] = player_id -2747 rebuilt_json[player_id]['player_name'] = player_name -2748 rebuilt_json[player_id]['home_away'] = home_away -2749 rebuilt_json[player_id]['kickReturns_TD'] = player_stat -2750 -2751 elif stat['name'] == "LONG": # kickReturns_LONG -2752 for i in stat['athletes']: -2753 player_id = int(i['id']) -2754 player_name = i['name'] -2755 player_stat = int(i['stat']) -2756 -2757 if rebuilt_json.get(player_id) == None: -2758 rebuilt_json[player_id] = {} -2759 -2760 rebuilt_json[player_id]['game_id'] = game_id -2761 rebuilt_json[player_id]['team_name'] = team_name -2762 rebuilt_json[player_id]['team_confrence'] = team_confrence -2763 rebuilt_json[player_id]['player_id'] = player_id -2764 rebuilt_json[player_id]['player_name'] = player_name -2765 rebuilt_json[player_id]['home_away'] = home_away -2766 rebuilt_json[player_id]['kickReturns_LONG'] = player_stat -2767 -2768 else: -2769 raise IndexError( -2770 f"Unhandled stat: \t{stat['name']}") -2771 -2772 elif s_category['name'] == "puntReturns": -2773 for stat in s_category['types']: -2774 if stat['name'] == "NO": # puntReturns_NO -2775 for i in stat['athletes']: -2776 player_id = int(i['id']) -2777 player_name = i['name'] -2778 player_stat = int(i['stat']) -2779 -2780 if rebuilt_json.get(player_id) == None: -2781 rebuilt_json[player_id] = {} -2782 -2783 rebuilt_json[player_id]['game_id'] = game_id -2784 rebuilt_json[player_id]['team_name'] = team_name -2785 rebuilt_json[player_id]['team_confrence'] = team_confrence -2786 rebuilt_json[player_id]['player_id'] = player_id -2787 rebuilt_json[player_id]['player_name'] = player_name -2788 rebuilt_json[player_id]['home_away'] = home_away -2789 rebuilt_json[player_id]['puntReturns_NO'] = player_stat -2790 -2791 elif stat['name'] == "YDS": # puntReturns_YDS -2792 for i in stat['athletes']: -2793 player_id = int(i['id']) -2794 player_name = i['name'] -2795 player_stat = int(i['stat']) -2796 -2797 if rebuilt_json.get(player_id) == None: -2798 rebuilt_json[player_id] = {} -2799 -2800 rebuilt_json[player_id]['game_id'] = game_id -2801 rebuilt_json[player_id]['team_name'] = team_name -2802 rebuilt_json[player_id]['team_confrence'] = team_confrence -2803 rebuilt_json[player_id]['player_id'] = player_id -2804 rebuilt_json[player_id]['player_name'] = player_name -2805 rebuilt_json[player_id]['home_away'] = home_away -2806 rebuilt_json[player_id]['puntReturns_YDS'] = player_stat -2807 -2808 elif stat['name'] == "AVG": # puntReturns_AVG -2809 for i in stat['athletes']: -2810 player_id = int(i['id']) -2811 player_name = i['name'] -2812 player_stat = float(i['stat']) -2813 -2814 if rebuilt_json.get(player_id) == None: -2815 rebuilt_json[player_id] = {} -2816 -2817 rebuilt_json[player_id]['game_id'] = game_id -2818 rebuilt_json[player_id]['team_name'] = team_name -2819 rebuilt_json[player_id]['team_confrence'] = team_confrence -2820 rebuilt_json[player_id]['player_id'] = player_id -2821 rebuilt_json[player_id]['player_name'] = player_name -2822 rebuilt_json[player_id]['home_away'] = home_away -2823 rebuilt_json[player_id]['puntReturns_AVG'] = player_stat -2824 -2825 elif stat['name'] == "TD": # puntReturns_TD -2826 for i in stat['athletes']: -2827 player_id = int(i['id']) -2828 player_name = i['name'] -2829 player_stat = int(i['stat']) -2830 -2831 if rebuilt_json.get(player_id) == None: -2832 rebuilt_json[player_id] = {} -2833 -2834 rebuilt_json[player_id]['game_id'] = game_id -2835 rebuilt_json[player_id]['team_name'] = team_name -2836 rebuilt_json[player_id]['team_confrence'] = team_confrence -2837 rebuilt_json[player_id]['player_id'] = player_id -2838 rebuilt_json[player_id]['player_name'] = player_name -2839 rebuilt_json[player_id]['home_away'] = home_away -2840 rebuilt_json[player_id]['puntReturns_TD'] = player_stat -2841 -2842 elif stat['name'] == "LONG": # puntReturns_LONG -2843 for i in stat['athletes']: -2844 player_id = int(i['id']) -2845 player_name = i['name'] -2846 player_stat = int(i['stat']) -2847 -2848 if rebuilt_json.get(player_id) == None: -2849 rebuilt_json[player_id] = {} -2850 -2851 rebuilt_json[player_id]['game_id'] = game_id -2852 rebuilt_json[player_id]['team_name'] = team_name -2853 rebuilt_json[player_id]['team_confrence'] = team_confrence -2854 rebuilt_json[player_id]['player_id'] = player_id -2855 rebuilt_json[player_id]['player_name'] = player_name -2856 rebuilt_json[player_id]['home_away'] = home_away -2857 rebuilt_json[player_id]['puntReturns_LONG'] = player_stat -2858 -2859 else: -2860 raise IndexError( -2861 f"Unhandled stat: \t{stat['name']}") -2862 -2863 else: -2864 raise IndexError( -2865 f"Unhandled stat category: \t{s_category['name']}" -2866 ) -2867 -2868 for key, value in tqdm(rebuilt_json.items()): -2869 # print(key) -2870 -2871 # print(value) -2872 game_id = value['game_id'] -2873 team_name = value['team_name'] -2874 team_confrence = value['team_confrence'] -2875 player_id = value['player_id'] -2876 player_name = value['player_name'] -2877 home_away = value['home_away'] -2878 -2879 row_df = pd.DataFrame( -2880 { -2881 "game_id": game_id, -2882 "team_name": team_name, -2883 "team_confrence": team_confrence, -2884 "player_id": player_id, -2885 "player_name": player_name, -2886 "home_away": home_away -2887 }, -2888 index=[0] -2889 ) -2890 # Passing -2891 if value.get('passing_C/ATT') != None: -2892 row_df['passing_C/ATT'] = value['passing_C/ATT'] -2893 -2894 if value.get('passing_YDS') != None: -2895 row_df['passing_YDS'] = value['passing_YDS'] -2896 -2897 if value.get('passing_AVG') != None: -2898 row_df['passing_AVG'] = value['passing_AVG'] -2899 -2900 if value.get('passing_TD') != None: -2901 row_df['passing_TD'] = value['passing_TD'] -2902 -2903 if value.get('passing_INT') != None: -2904 row_df['passing_INT'] = value['passing_INT'] -2905 -2906 if value.get('passing_QBR') != None: -2907 row_df['passing_QBR'] = value['passing_QBR'] -2908 -2909 # Rushing -2910 if value.get('rushing_CAR') != None: -2911 row_df['rushing_CAR'] = value['rushing_CAR'] -2912 -2913 if value.get('rushing_YDS') != None: -2914 row_df['rushing_YDS'] = value['rushing_YDS'] -2915 -2916 if value.get('rushing_AVG') != None: -2917 row_df['rushing_AVG'] = value['rushing_AVG'] -2918 -2919 if value.get('rushing_TD') != None: -2920 row_df['rushing_TD'] = value['rushing_TD'] -2921 -2922 if value.get('rushing_LONG') != None: -2923 row_df['rushing_LONG'] = value['rushing_LONG'] -2924 -2925 # Receiving -2926 if value.get('receiving_REC') != None: -2927 row_df['receiving_REC'] = value['receiving_REC'] -2928 -2929 if value.get('receiving_YDS') != None: -2930 row_df['receiving_YDS'] = value['receiving_YDS'] -2931 -2932 if value.get('receiving_AVG') != None: -2933 row_df['receiving_AVG'] = value['receiving_AVG'] -2934 -2935 if value.get('receiving_TD') != None: -2936 row_df['receiving_TD'] = value['receiving_TD'] -2937 -2938 if value.get('receiving_LONG') != None: -2939 row_df['receiving_LONG'] = value['receiving_LONG'] -2940 -2941 # Fumbles -2942 if value.get('fumbles_FUM') != None: -2943 row_df['fumbles_FUM'] = value['fumbles_FUM'] -2944 -2945 if value.get('fumbles_LOST') != None: -2946 row_df['fumbles_LOST'] = value['fumbles_LOST'] -2947 -2948 if value.get('fumbles_REC') != None: -2949 row_df['fumbles_REC'] = value['fumbles_REC'] -2950 -2951 # Defense -2952 if value.get('defensive_TOT') != None: -2953 row_df['defensive_TOT'] = value['defensive_TOT'] -2954 -2955 if value.get('defensive_SOLO') != None: -2956 row_df['defensive_SOLO'] = value['defensive_SOLO'] -2957 -2958 if value.get('defensive_TFL') != None: -2959 row_df['defensive_TFL'] = value['defensive_TFL'] -2960 -2961 if value.get('defensive_QB HUR') != None: -2962 row_df['defensive_QB HUR'] = value['defensive_QB HUR'] -2963 -2964 if value.get('defensive_SACKS') != None: -2965 row_df['defensive_SACKS'] = value['defensive_SACKS'] -2966 -2967 if value.get('defensive_PD') != None: -2968 row_df['defensive_PD'] = value['defensive_PD'] -2969 -2970 if value.get('defensive_TD') != None: -2971 row_df['defensive_TD'] = value['defensive_TD'] -2972 -2973 # interceptions -2974 if value.get('interceptions_INT') != None: -2975 row_df['interceptions_INT'] = value['interceptions_INT'] -2976 -2977 if value.get('interceptions_YDS') != None: -2978 row_df['interceptions_YDS'] = value['interceptions_YDS'] -2979 -2980 if value.get('interceptions_TD') != None: -2981 row_df['interceptions_TD'] = value['interceptions_TD'] -2982 -2983 # punting -2984 if value.get('punting_NO') != None: -2985 row_df['punting_NO'] = value['punting_NO'] -2986 -2987 if value.get('punting_YDS') != None: -2988 row_df['punting_YDS'] = value['punting_YDS'] -2989 -2990 if value.get('punting_AVG') != None: -2991 row_df['punting_AVG'] = value['punting_AVG'] -2992 -2993 if value.get('punting_TB') != None: -2994 row_df['punting_TB'] = value['punting_TB'] -2995 -2996 if value.get('punting_In 20') != None: -2997 row_df['punting_In 20'] = value['punting_In 20'] -2998 -2999 if value.get('punting_LONG') != None: -3000 row_df['punting_LONG'] = value['punting_LONG'] -3001 -3002 # kicking -3003 if value.get('kicking_FG') != None: -3004 row_df['kicking_FG'] = value['kicking_FG'] -3005 -3006 if value.get('kicking_PCT') != None: -3007 row_df['kicking_PCT'] = value['kicking_PCT'] -3008 -3009 if value.get('kicking_LONG') != None: -3010 row_df['kicking_LONG'] = value['kicking_LONG'] -3011 -3012 if value.get('kicking_XP') != None: -3013 row_df['kicking_XP'] = value['kicking_XP'] -3014 -3015 if value.get('kicking_PTS') != None: -3016 row_df['kicking_PTS'] = value['kicking_PTS'] -3017 -3018 # kickReturns -3019 if value.get('kickReturns_NO') != None: -3020 row_df['kickReturns_NO'] = value['kickReturns_NO'] -3021 -3022 if value.get('kickReturns_YDS') != None: -3023 row_df['kickReturns_YDS'] = value['kickReturns_YDS'] -3024 -3025 if value.get('kickReturns_AVG') != None: -3026 row_df['kickReturns_AVG'] = value['kickReturns_AVG'] -3027 -3028 if value.get('kickReturns_TD') != None: -3029 row_df['kickReturns_TD'] = value['kickReturns_TD'] -3030 -3031 if value.get('kickReturns_LONG') != None: -3032 row_df['kickReturns_LONG'] = value['kickReturns_LONG'] -3033 -3034 # puntReturns -3035 if value.get('puntReturns_NO') != None: -3036 row_df['puntReturns_NO'] = value['puntReturns_NO'] -3037 -3038 if value.get('puntReturns_YDS') != None: -3039 row_df['puntReturns_YDS'] = value['puntReturns_YDS'] -3040 -3041 if value.get('puntReturns_AVG') != None: -3042 row_df['puntReturns_AVG'] = value['puntReturns_AVG'] -3043 -3044 if value.get('puntReturns_TD') != None: -3045 row_df['puntReturns_TD'] = value['puntReturns_TD'] -3046 -3047 if value.get('puntReturns_LONG') != None: -3048 row_df['puntReturns_LONG'] = value['puntReturns_LONG'] -3049 -3050 cfb_games_df = pd.concat([cfb_games_df, row_df], ignore_index=True) -3051 del row_df -3052 -3053 cfb_games_df[['passing_COMP', 'passing_ATT'] -3054 ] = cfb_games_df['passing_C/ATT'].str.split('/', expand=True) -3055 -3056 cfb_games_df[['kicking_FGM', 'kicking_FGA'] -3057 ] = cfb_games_df['kicking_FG'].str.split('/', expand=True) -3058 cfb_games_df[['kicking_XPM', 'kicking_XPA'] -3059 ] = cfb_games_df['kicking_XP'].str.split('/', expand=True) -3060 -3061 cfb_games_df = cfb_games_df.fillna(0) -3062 -3063 cfb_games_df = cfb_games_df.astype({ -3064 "passing_COMP": "int", -3065 "passing_ATT": "int", -3066 "kicking_FGM": "int", -3067 "kicking_FGA": "int", -3068 "kicking_XPM": "int", -3069 "kicking_XPA": "int" -3070 }) -3071 # print(cfb_games_df.columns) -3072 -3073 if filter_by_stat_category == False: -3074 cfb_games_df = cfb_games_df.reindex(columns=stat_columns) -3075 -3076 elif filter_by_stat_category == True and stat_category == "passing": -3077 cfb_games_df = cfb_games_df[[ -3078 'game_id', -3079 'team_name', -3080 'team_confrence', -3081 'player_id', -3082 'player_name', -3083 'home_away', -3084 # PASS -3085 'passing_C/ATT', -3086 'passing_COMP', -3087 'passing_ATT', -3088 'passing_YDS', -3089 'passing_AVG', -3090 'passing_TD', -3091 'passing_INT', -3092 'passing_QBR' -3093 ]] -3094 -3095 elif filter_by_stat_category == True and stat_category == "rushing": -3096 cfb_games_df = cfb_games_df[[ -3097 'game_id', -3098 'team_name', -3099 'team_confrence', -3100 'player_id', -3101 'player_name', -3102 'home_away', -3103 # RUSH -3104 'rushing_CAR', -3105 'rushing_YDS', -3106 'rushing_AVG', -3107 'rushing_TD', -3108 'rushing_LONG', -3109 ]] -3110 -3111 elif filter_by_stat_category == True and stat_category == "receiving": -3112 cfb_games_df = cfb_games_df[[ -3113 'game_id', -3114 'team_name', -3115 'team_confrence', -3116 'player_id', -3117 'player_name', -3118 'home_away', -3119 # REC -3120 'receiving_REC', -3121 'receiving_YDS', -3122 'receiving_AVG', -3123 'receiving_TD', -3124 'receiving_LONG' -3125 ]] -3126 -3127 elif filter_by_stat_category == True and stat_category == "fumbles": -3128 cfb_games_df = cfb_games_df[[ -3129 'game_id', -3130 'team_name', -3131 'team_confrence', -3132 'player_id', -3133 'player_name', -3134 'home_away', -3135 # FUM -3136 'fumbles_FUM', -3137 'fumbles_LOST', -3138 'fumbles_REC' -3139 ]] -3140 -3141 elif filter_by_stat_category == True and stat_category == "defensive": -3142 cfb_games_df = cfb_games_df[[ -3143 'game_id', -3144 'team_name', -3145 'team_confrence', -3146 'player_id', -3147 'player_name', -3148 'home_away', -3149 # DEFENSE -3150 'defensive_TOT', -3151 'defensive_SOLO', -3152 'defensive_TFL', -3153 'defensive_QB HUR', -3154 'defensive_SACKS', -3155 'defensive_PD', -3156 'defensive_TD' -3157 ]] -3158 -3159 elif filter_by_stat_category == True and stat_category == "interceptions": -3160 cfb_games_df = cfb_games_df[[ -3161 'game_id', -3162 'team_name', -3163 'team_confrence', -3164 'player_id', -3165 'player_name', -3166 'home_away', -3167 # INT -3168 'interceptions_INT', -3169 'interceptions_YDS', -3170 'interceptions_TD', -3171 ]] -3172 -3173 elif filter_by_stat_category == True and stat_category == "punting": -3174 cfb_games_df = cfb_games_df[[ -3175 'game_id', -3176 'team_name', -3177 'team_confrence', -3178 'player_id', -3179 'player_name', -3180 'home_away', -3181 # PUNT -3182 'punting_NO', -3183 'punting_YDS', -3184 'punting_AVG', -3185 'punting_TB', -3186 'punting_In 20', -3187 'punting_LONG' -3188 ]] -3189 -3190 elif filter_by_stat_category == True and stat_category == "kicking": -3191 cfb_games_df = cfb_games_df[[ -3192 'game_id', -3193 'team_name', -3194 'team_confrence', -3195 'player_id', -3196 'player_name', -3197 'home_away', -3198 # KICK -3199 'kicking_FG', -3200 'kicking_FGM', -3201 'kicking_FGA', -3202 'kicking_PCT', -3203 'kicking_LONG', -3204 'kicking_XP', -3205 'kicking_XPM', -3206 'kicking_XPA', -3207 'kicking_PTS' -3208 ]] -3209 -3210 elif filter_by_stat_category == True and stat_category == "kickReturns": -3211 cfb_games_df = cfb_games_df[[ -3212 'game_id', -3213 'team_name', -3214 'team_confrence', -3215 'player_id', -3216 'player_name', -3217 'home_away', -3218 # KR -3219 'kickReturns_NO', -3220 'kickReturns_YDS', -3221 'kickReturns_AVG', -3222 'kickReturns_TD', -3223 'kickReturns_LONG' -3224 ]] -3225 -3226 elif filter_by_stat_category == True and stat_category == "puntReturns": -3227 cfb_games_df = cfb_games_df[[ -3228 'game_id', -3229 'team_name', -3230 'team_confrence', -3231 'player_id', -3232 'player_name', -3233 'home_away', -3234 # KR -3235 'puntReturns_NO', -3236 'puntReturns_YDS', -3237 'puntReturns_AVG', -3238 'puntReturns_TD', -3239 'puntReturns_LONG' -3240 ]] -3241 -3242 return cfb_games_df -3243 -3244 -3245def get_cfbd_player_advanced_game_stats( -3246 game_id: int, -3247 api_key: str = None, -3248 api_key_dir: str = None, -3249 return_as_dict: bool = False): -3250 """ -3251 Retrives advanced game stats from the CFBD API. -3252 -3253 Parameters -3254 ---------- +1696 'season', +1697 'game_id', +1698 'team_name', +1699 'team_confrence', +1700 'player_id', +1701 'player_name', +1702 'home_away', +1703 # PASS +1704 'passing_C/ATT', +1705 'passing_COMP', +1706 'passing_ATT', +1707 'passing_YDS', +1708 'passing_AVG', +1709 'passing_TD', +1710 'passing_INT', +1711 'passing_QBR', +1712 # RUSH +1713 'rushing_CAR', +1714 'rushing_YDS', +1715 'rushing_AVG', +1716 'rushing_TD', +1717 'rushing_LONG', +1718 # REC +1719 'receiving_REC', +1720 'receiving_YDS', +1721 'receiving_AVG', +1722 'receiving_TD', +1723 'receiving_LONG', +1724 # FUM +1725 'fumbles_FUM', +1726 'fumbles_LOST', +1727 'fumbles_REC', +1728 # DEFENSE +1729 'defensive_TOT', +1730 'defensive_SOLO', +1731 'defensive_TFL', +1732 'defensive_QB HUR', +1733 'defensive_SACKS', +1734 'defensive_PD', +1735 'defensive_TD', +1736 # INT +1737 'interceptions_INT', +1738 'interceptions_YDS', +1739 'interceptions_TD', +1740 # PUNT +1741 'punting_NO', +1742 'punting_YDS', +1743 'punting_AVG', +1744 'punting_TB', +1745 'punting_In 20', +1746 'punting_LONG', +1747 # KICK +1748 'kicking_FG', +1749 'kicking_FGM', +1750 'kicking_FGA', +1751 'kicking_PCT', +1752 'kicking_LONG', +1753 'kicking_XP', +1754 'kicking_XPM', +1755 'kicking_XPA', +1756 'kicking_PTS', +1757 # KR +1758 'kickReturns_NO', +1759 'kickReturns_YDS', +1760 'kickReturns_AVG', +1761 'kickReturns_TD', +1762 'kickReturns_LONG', +1763 # PR +1764 'puntReturns_NO', +1765 'puntReturns_YDS', +1766 'puntReturns_AVG', +1767 'puntReturns_TD', +1768 'puntReturns_LONG' +1769 ] +1770 +1771 ######################################################################################################################################################################################################## +1772 +1773 if api_key != None: +1774 real_api_key = api_key +1775 del api_key +1776 else: +1777 real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) +1778 +1779 if real_api_key == "tigersAreAwsome": +1780 raise ValueError( +1781 "You actually need to change `cfbd_key` to your CFBD API key.") +1782 elif "Bearer " in real_api_key: +1783 pass +1784 elif "Bearer" in real_api_key: +1785 real_api_key = real_api_key.replace('Bearer', 'Bearer ') +1786 else: +1787 real_api_key = "Bearer " + real_api_key +1788 +1789 if season == None: +1790 # This should never happen without user tampering, but if it does, +1791 # we need to raise an error, because the CFBD API will refuse this call without a valid season. +1792 raise SystemError( +1793 "I don't know how, I don't know why, " + +1794 "but you managed to call this function while `season` was `None` (NULL)," + +1795 " and the function got to this point in the code." + +1796 "\nIf you have a GitHub account, " + +1797 "please raise an issue on this python package's GitHub page:\n" + +1798 "https://github.com/armstjc/cfbd-json-py/issues" +1799 ) +1800 elif season > (now.year + 1): +1801 raise ValueError(f"`season` cannot be greater than {season}.") +1802 elif season < 1869: +1803 raise ValueError(f"`season` cannot be less than 1869.") +1804 +1805 if season_type != "regular" and season_type != "postseason": +1806 raise ValueError( +1807 "`season_type` must be set to either \"regular\" or " + +1808 "\"postseason\" for this function to work." +1809 ) +1810 +1811 # `week`, `team`, and/or `conference` +1812 # must be not null for this function to work. +1813 +1814 if week == None and team == None and conference_abv == None and game_id == None: +1815 raise ValueError( +1816 "To use `get_cfbd_player_game_stats()`," + +1817 " `week`, `team`, and/or `conference_abv` need to be set to a non-null value." +1818 ) +1819 +1820 filter_by_stat_category = False +1821 +1822 if stat_category == None: +1823 pass +1824 elif stat_category == "passing": +1825 filter_by_stat_category = True +1826 elif stat_category == "rushing": +1827 filter_by_stat_category = True +1828 elif stat_category == "receiving": +1829 filter_by_stat_category = True +1830 elif stat_category == "fumbles": +1831 filter_by_stat_category = True +1832 elif stat_category == "passing": +1833 filter_by_stat_category = True +1834 elif stat_category == "defensive": +1835 filter_by_stat_category = True +1836 elif stat_category == "interceptions": +1837 filter_by_stat_category = True +1838 elif stat_category == "punting": +1839 filter_by_stat_category = True +1840 elif stat_category == "kicking": +1841 filter_by_stat_category = True +1842 elif stat_category == "kickReturns": +1843 filter_by_stat_category = True +1844 elif stat_category == "puntReturns": +1845 filter_by_stat_category = True +1846 else: +1847 raise ValueError( +1848 "Invalid input for `stat_category`." + +1849 "\nValid inputs are:" + +1850 """ +1851 - `passing` +1852 - `rushing` +1853 - `receiving` +1854 - `fumbles` +1855 - `defensive` +1856 - `interceptions` +1857 - `punting` +1858 - `kicking` +1859 - `kickReturns` +1860 - `puntReturns` +1861 """ +1862 ) +1863 +1864 # URL builder +1865 ######################################################################################################################################################################################################## +1866 +1867 # Required by the API +1868 url += f"?year={season}" +1869 +1870 if game_id != None: +1871 url += f"&gameId={game_id}" +1872 +1873 if stat_category != None: +1874 url += f"&category={stat_category}" +1875 +1876 if week != None or team != None or conference_abv != None: +1877 logging.warning( +1878 "When calling `cfbd_json_py.games.get_cfbd_player_game_stats()`, " + +1879 "and setting `game_id` to a non-null value, " + +1880 "only `season`, `stat_category`, and `game_id` are considered " + +1881 "when calling the CFBD API." +1882 ) +1883 else: +1884 if season_type != None: +1885 url += f"&seasonType={season_type}" +1886 +1887 if week != None: +1888 url += f"&week={week}" +1889 +1890 if team != None: +1891 url += f"&team={team}" +1892 +1893 if conference_abv != None: +1894 url += f"&conference={conference_abv}" +1895 +1896 headers = { +1897 'Authorization': f'{real_api_key}', +1898 'accept': 'application/json' +1899 } +1900 +1901 response = requests.get(url, headers=headers) +1902 +1903 +1904 if response.status_code == 200: +1905 pass +1906 elif response.status_code == 401: +1907 raise ConnectionRefusedError( +1908 f'Could not connect. The connection was refused.\nHTTP Status Code 401.' +1909 ) +1910 else: +1911 raise ConnectionError( +1912 f'Could not connect.\nHTTP Status code {response.status_code}' +1913 ) +1914 +1915 json_data = response.json() +1916 +1917 if return_as_dict == True: +1918 return json_data +1919 +1920 for game in tqdm(json_data): +1921 game_id = game['id'] +1922 +1923 for team in game['teams']: +1924 team_name = team['school'] +1925 team_confrence = team['conference'] +1926 home_away = team['homeAway'] +1927 +1928 for s_category in team['categories']: +1929 if s_category['name'] == "passing": +1930 for stat in s_category['types']: +1931 +1932 if stat['name'] == "C/ATT": # passing_C/ATT +1933 +1934 for i in stat['athletes']: +1935 player_id = int(i['id']) +1936 player_name = i['name'] +1937 player_stat = i['stat'] +1938 +1939 if rebuilt_json.get(player_id) == None: +1940 rebuilt_json[player_id] = {} +1941 +1942 rebuilt_json[player_id]['game_id'] = game_id +1943 rebuilt_json[player_id]['team_name'] = team_name +1944 rebuilt_json[player_id]['team_confrence'] = team_confrence +1945 rebuilt_json[player_id]['player_id'] = player_id +1946 rebuilt_json[player_id]['player_name'] = player_name +1947 rebuilt_json[player_id]['home_away'] = home_away +1948 rebuilt_json[player_id]['passing_C/ATT'] = player_stat +1949 +1950 elif stat['name'] == "YDS": # passing_YDS +1951 +1952 for i in stat['athletes']: +1953 player_id = int(i['id']) +1954 player_name = i['name'] +1955 player_stat = int(i['stat']) +1956 +1957 if rebuilt_json.get(player_id) == None: +1958 rebuilt_json[player_id] = {} +1959 +1960 rebuilt_json[player_id]['game_id'] = game_id +1961 rebuilt_json[player_id]['team_name'] = team_name +1962 rebuilt_json[player_id]['team_confrence'] = team_confrence +1963 rebuilt_json[player_id]['player_id'] = player_id +1964 rebuilt_json[player_id]['player_name'] = player_name +1965 rebuilt_json[player_id]['home_away'] = home_away +1966 rebuilt_json[player_id]['passing_YDS'] = player_stat +1967 +1968 elif stat['name'] == "AVG": # passing_AVG +1969 for i in stat['athletes']: +1970 player_id = int(i['id']) +1971 player_name = i['name'] +1972 player_stat = float(i['stat']) +1973 +1974 if rebuilt_json.get(player_id) == None: +1975 rebuilt_json[player_id] = {} +1976 +1977 rebuilt_json[player_id]['game_id'] = game_id +1978 rebuilt_json[player_id]['team_name'] = team_name +1979 rebuilt_json[player_id]['team_confrence'] = team_confrence +1980 rebuilt_json[player_id]['player_id'] = player_id +1981 rebuilt_json[player_id]['player_name'] = player_name +1982 rebuilt_json[player_id]['home_away'] = home_away +1983 rebuilt_json[player_id]['passing_AVG'] = player_stat +1984 +1985 elif stat['name'] == "TD": # passing_TD +1986 +1987 for i in stat['athletes']: +1988 player_id = int(i['id']) +1989 player_name = i['name'] +1990 player_stat = int(i['stat']) +1991 +1992 if rebuilt_json.get(player_id) == None: +1993 rebuilt_json[player_id] = {} +1994 +1995 rebuilt_json[player_id]['game_id'] = game_id +1996 rebuilt_json[player_id]['team_name'] = team_name +1997 rebuilt_json[player_id]['team_confrence'] = team_confrence +1998 rebuilt_json[player_id]['player_id'] = player_id +1999 rebuilt_json[player_id]['player_name'] = player_name +2000 rebuilt_json[player_id]['home_away'] = home_away +2001 rebuilt_json[player_id]['passing_TD'] = player_stat +2002 +2003 elif stat['name'] == "INT": # passing_INT +2004 +2005 for i in stat['athletes']: +2006 player_id = int(i['id']) +2007 player_name = i['name'] +2008 player_stat = int(i['stat']) +2009 +2010 if rebuilt_json.get(player_id) == None: +2011 rebuilt_json[player_id] = {} +2012 +2013 rebuilt_json[player_id]['game_id'] = game_id +2014 rebuilt_json[player_id]['team_name'] = team_name +2015 rebuilt_json[player_id]['team_confrence'] = team_confrence +2016 rebuilt_json[player_id]['player_id'] = player_id +2017 rebuilt_json[player_id]['player_name'] = player_name +2018 rebuilt_json[player_id]['home_away'] = home_away +2019 rebuilt_json[player_id]['passing_INT'] = player_stat +2020 +2021 elif stat['name'] == "QBR": # passing_QBR +2022 for i in stat['athletes']: +2023 player_id = int(i['id']) +2024 player_name = i['name'] +2025 try: +2026 player_stat = float(i['stat']) +2027 except: +2028 player_stat = None +2029 +2030 if rebuilt_json.get(player_id) == None: +2031 rebuilt_json[player_id] = {} +2032 +2033 rebuilt_json[player_id]['game_id'] = game_id +2034 rebuilt_json[player_id]['team_name'] = team_name +2035 rebuilt_json[player_id]['team_confrence'] = team_confrence +2036 rebuilt_json[player_id]['player_id'] = player_id +2037 rebuilt_json[player_id]['player_name'] = player_name +2038 rebuilt_json[player_id]['home_away'] = home_away +2039 rebuilt_json[player_id]['passing_QBR'] = player_stat +2040 +2041 else: +2042 raise IndexError( +2043 f"Unhandled stat: \t{stat['name']}") +2044 # passing_df = pd.DataFrame(s_category['types']) +2045 elif s_category['name'] == "rushing": +2046 for stat in s_category['types']: +2047 if stat['name'] == "CAR": # rushing_CAR +2048 for i in stat['athletes']: +2049 player_id = int(i['id']) +2050 player_name = i['name'] +2051 player_stat = int(i['stat']) +2052 +2053 if rebuilt_json.get(player_id) == None: +2054 rebuilt_json[player_id] = {} +2055 +2056 rebuilt_json[player_id]['game_id'] = game_id +2057 rebuilt_json[player_id]['team_name'] = team_name +2058 rebuilt_json[player_id]['team_confrence'] = team_confrence +2059 rebuilt_json[player_id]['player_id'] = player_id +2060 rebuilt_json[player_id]['player_name'] = player_name +2061 rebuilt_json[player_id]['home_away'] = home_away +2062 rebuilt_json[player_id]['rushing_CAR'] = player_stat +2063 +2064 elif stat['name'] == "YDS": # rushing_YDS +2065 for i in stat['athletes']: +2066 player_id = int(i['id']) +2067 player_name = i['name'] +2068 player_stat = int(i['stat']) +2069 +2070 if rebuilt_json.get(player_id) == None: +2071 rebuilt_json[player_id] = {} +2072 +2073 rebuilt_json[player_id]['game_id'] = game_id +2074 rebuilt_json[player_id]['team_name'] = team_name +2075 rebuilt_json[player_id]['team_confrence'] = team_confrence +2076 rebuilt_json[player_id]['player_id'] = player_id +2077 rebuilt_json[player_id]['player_name'] = player_name +2078 rebuilt_json[player_id]['home_away'] = home_away +2079 rebuilt_json[player_id]['rushing_YDS'] = player_stat +2080 +2081 elif stat['name'] == "AVG": # rushing_AVG +2082 for i in stat['athletes']: +2083 player_id = int(i['id']) +2084 player_name = i['name'] +2085 player_stat = float(i['stat']) +2086 +2087 if rebuilt_json.get(player_id) == None: +2088 rebuilt_json[player_id] = {} +2089 +2090 rebuilt_json[player_id]['game_id'] = game_id +2091 rebuilt_json[player_id]['team_name'] = team_name +2092 rebuilt_json[player_id]['team_confrence'] = team_confrence +2093 rebuilt_json[player_id]['player_id'] = player_id +2094 rebuilt_json[player_id]['player_name'] = player_name +2095 rebuilt_json[player_id]['home_away'] = home_away +2096 rebuilt_json[player_id]['rushing_AVG'] = player_stat +2097 +2098 elif stat['name'] == "TD": # rushing_TD +2099 for i in stat['athletes']: +2100 player_id = int(i['id']) +2101 player_name = i['name'] +2102 player_stat = int(i['stat']) +2103 +2104 if rebuilt_json.get(player_id) == None: +2105 rebuilt_json[player_id] = {} +2106 +2107 rebuilt_json[player_id]['game_id'] = game_id +2108 rebuilt_json[player_id]['team_name'] = team_name +2109 rebuilt_json[player_id]['team_confrence'] = team_confrence +2110 rebuilt_json[player_id]['player_id'] = player_id +2111 rebuilt_json[player_id]['player_name'] = player_name +2112 rebuilt_json[player_id]['home_away'] = home_away +2113 rebuilt_json[player_id]['rushing_TD'] = player_stat +2114 +2115 elif stat['name'] == "LONG": # rushing_LONG +2116 for i in stat['athletes']: +2117 player_id = int(i['id']) +2118 player_name = i['name'] +2119 player_stat = int(i['stat']) +2120 +2121 if rebuilt_json.get(player_id) == None: +2122 rebuilt_json[player_id] = {} +2123 +2124 rebuilt_json[player_id]['game_id'] = game_id +2125 rebuilt_json[player_id]['team_name'] = team_name +2126 rebuilt_json[player_id]['team_confrence'] = team_confrence +2127 rebuilt_json[player_id]['player_id'] = player_id +2128 rebuilt_json[player_id]['player_name'] = player_name +2129 rebuilt_json[player_id]['home_away'] = home_away +2130 rebuilt_json[player_id]['rushing_LONG'] = player_stat +2131 +2132 else: +2133 raise IndexError( +2134 f"Unhandled stat: \t{stat['name']}") +2135 +2136 elif s_category['name'] == "receiving": +2137 for stat in s_category['types']: +2138 if stat['name'] == "REC": # receiving_REC +2139 for i in stat['athletes']: +2140 player_id = int(i['id']) +2141 player_name = i['name'] +2142 player_stat = int(i['stat']) +2143 +2144 if rebuilt_json.get(player_id) == None: +2145 rebuilt_json[player_id] = {} +2146 +2147 rebuilt_json[player_id]['game_id'] = game_id +2148 rebuilt_json[player_id]['team_name'] = team_name +2149 rebuilt_json[player_id]['team_confrence'] = team_confrence +2150 rebuilt_json[player_id]['player_id'] = player_id +2151 rebuilt_json[player_id]['player_name'] = player_name +2152 rebuilt_json[player_id]['home_away'] = home_away +2153 rebuilt_json[player_id]['receiving_REC'] = player_stat +2154 +2155 elif stat['name'] == "YDS": # receiving_YDS +2156 for i in stat['athletes']: +2157 player_id = int(i['id']) +2158 player_name = i['name'] +2159 player_stat = int(i['stat']) +2160 +2161 if rebuilt_json.get(player_id) == None: +2162 rebuilt_json[player_id] = {} +2163 +2164 rebuilt_json[player_id]['game_id'] = game_id +2165 rebuilt_json[player_id]['team_name'] = team_name +2166 rebuilt_json[player_id]['team_confrence'] = team_confrence +2167 rebuilt_json[player_id]['player_id'] = player_id +2168 rebuilt_json[player_id]['player_name'] = player_name +2169 rebuilt_json[player_id]['home_away'] = home_away +2170 rebuilt_json[player_id]['receiving_YDS'] = player_stat +2171 +2172 elif stat['name'] == "AVG": # receiving_AVG +2173 for i in stat['athletes']: +2174 player_id = int(i['id']) +2175 player_name = i['name'] +2176 player_stat = float(i['stat']) +2177 +2178 if rebuilt_json.get(player_id) == None: +2179 rebuilt_json[player_id] = {} +2180 +2181 rebuilt_json[player_id]['game_id'] = game_id +2182 rebuilt_json[player_id]['team_name'] = team_name +2183 rebuilt_json[player_id]['team_confrence'] = team_confrence +2184 rebuilt_json[player_id]['player_id'] = player_id +2185 rebuilt_json[player_id]['player_name'] = player_name +2186 rebuilt_json[player_id]['home_away'] = home_away +2187 rebuilt_json[player_id]['receiving_AVG'] = player_stat +2188 +2189 elif stat['name'] == "TD": # receiving_TD +2190 for i in stat['athletes']: +2191 player_id = int(i['id']) +2192 player_name = i['name'] +2193 player_stat = int(i['stat']) +2194 +2195 if rebuilt_json.get(player_id) == None: +2196 rebuilt_json[player_id] = {} +2197 +2198 rebuilt_json[player_id]['game_id'] = game_id +2199 rebuilt_json[player_id]['team_name'] = team_name +2200 rebuilt_json[player_id]['team_confrence'] = team_confrence +2201 rebuilt_json[player_id]['player_id'] = player_id +2202 rebuilt_json[player_id]['player_name'] = player_name +2203 rebuilt_json[player_id]['home_away'] = home_away +2204 rebuilt_json[player_id]['receiving_TD'] = player_stat +2205 +2206 elif stat['name'] == "LONG": # receiving_LONG +2207 for i in stat['athletes']: +2208 player_id = int(i['id']) +2209 player_name = i['name'] +2210 player_stat = int(i['stat']) +2211 +2212 if rebuilt_json.get(player_id) == None: +2213 rebuilt_json[player_id] = {} +2214 +2215 rebuilt_json[player_id]['game_id'] = game_id +2216 rebuilt_json[player_id]['team_name'] = team_name +2217 rebuilt_json[player_id]['team_confrence'] = team_confrence +2218 rebuilt_json[player_id]['player_id'] = player_id +2219 rebuilt_json[player_id]['player_name'] = player_name +2220 rebuilt_json[player_id]['home_away'] = home_away +2221 rebuilt_json[player_id]['receiving_LONG'] = player_stat +2222 +2223 else: +2224 raise IndexError( +2225 f"Unhandled stat: \t{stat['name']}") +2226 +2227 elif s_category['name'] == "fumbles": +2228 for stat in s_category['types']: +2229 if stat['name'] == "FUM": # fumbles_FUM +2230 for i in stat['athletes']: +2231 player_id = int(i['id']) +2232 player_name = i['name'] +2233 player_stat = int(i['stat']) +2234 +2235 if rebuilt_json.get(player_id) == None: +2236 rebuilt_json[player_id] = {} +2237 +2238 rebuilt_json[player_id]['game_id'] = game_id +2239 rebuilt_json[player_id]['team_name'] = team_name +2240 rebuilt_json[player_id]['team_confrence'] = team_confrence +2241 rebuilt_json[player_id]['player_id'] = player_id +2242 rebuilt_json[player_id]['player_name'] = player_name +2243 rebuilt_json[player_id]['home_away'] = home_away +2244 rebuilt_json[player_id]['fumbles_FUM'] = player_stat +2245 +2246 elif stat['name'] == "LOST": # fumbles_LOST +2247 for i in stat['athletes']: +2248 player_id = int(i['id']) +2249 player_name = i['name'] +2250 player_stat = int(i['stat']) +2251 +2252 if rebuilt_json.get(player_id) == None: +2253 rebuilt_json[player_id] = {} +2254 +2255 rebuilt_json[player_id]['game_id'] = game_id +2256 rebuilt_json[player_id]['team_name'] = team_name +2257 rebuilt_json[player_id]['team_confrence'] = team_confrence +2258 rebuilt_json[player_id]['player_id'] = player_id +2259 rebuilt_json[player_id]['player_name'] = player_name +2260 rebuilt_json[player_id]['home_away'] = home_away +2261 rebuilt_json[player_id]['fumbles_LOST'] = player_stat +2262 +2263 elif stat['name'] == "REC": # fumbles_REC +2264 for i in stat['athletes']: +2265 player_id = int(i['id']) +2266 player_name = i['name'] +2267 player_stat = int(i['stat']) +2268 +2269 if rebuilt_json.get(player_id) == None: +2270 rebuilt_json[player_id] = {} +2271 +2272 rebuilt_json[player_id]['game_id'] = game_id +2273 rebuilt_json[player_id]['team_name'] = team_name +2274 rebuilt_json[player_id]['team_confrence'] = team_confrence +2275 rebuilt_json[player_id]['player_id'] = player_id +2276 rebuilt_json[player_id]['player_name'] = player_name +2277 rebuilt_json[player_id]['home_away'] = home_away +2278 rebuilt_json[player_id]['fumbles_REC'] = player_stat +2279 +2280 else: +2281 raise IndexError( +2282 f"Unhandled stat: \t{stat['name']}") +2283 +2284 elif s_category['name'] == "defensive": +2285 for stat in s_category['types']: +2286 if stat['name'] == "TOT": # defensive_TOT +2287 for i in stat['athletes']: +2288 player_id = int(i['id']) +2289 player_name = i['name'] +2290 player_stat = int(i['stat']) +2291 +2292 if rebuilt_json.get(player_id) == None: +2293 rebuilt_json[player_id] = {} +2294 +2295 rebuilt_json[player_id]['game_id'] = game_id +2296 rebuilt_json[player_id]['team_name'] = team_name +2297 rebuilt_json[player_id]['team_confrence'] = team_confrence +2298 rebuilt_json[player_id]['player_id'] = player_id +2299 rebuilt_json[player_id]['player_name'] = player_name +2300 rebuilt_json[player_id]['home_away'] = home_away +2301 rebuilt_json[player_id]['defensive_TOT'] = player_stat +2302 +2303 elif stat['name'] == "SOLO": # defensive_SOLO +2304 for i in stat['athletes']: +2305 player_id = int(i['id']) +2306 player_name = i['name'] +2307 player_stat = int(i['stat']) +2308 +2309 if rebuilt_json.get(player_id) == None: +2310 rebuilt_json[player_id] = {} +2311 +2312 rebuilt_json[player_id]['game_id'] = game_id +2313 rebuilt_json[player_id]['team_name'] = team_name +2314 rebuilt_json[player_id]['team_confrence'] = team_confrence +2315 rebuilt_json[player_id]['player_id'] = player_id +2316 rebuilt_json[player_id]['player_name'] = player_name +2317 rebuilt_json[player_id]['home_away'] = home_away +2318 rebuilt_json[player_id]['defensive_SOLO'] = player_stat +2319 +2320 elif stat['name'] == "TFL": # defensive_TFL +2321 for i in stat['athletes']: +2322 player_id = int(i['id']) +2323 player_name = i['name'] +2324 player_stat = float(i['stat']) +2325 +2326 if rebuilt_json.get(player_id) == None: +2327 rebuilt_json[player_id] = {} +2328 +2329 rebuilt_json[player_id]['game_id'] = game_id +2330 rebuilt_json[player_id]['team_name'] = team_name +2331 rebuilt_json[player_id]['team_confrence'] = team_confrence +2332 rebuilt_json[player_id]['player_id'] = player_id +2333 rebuilt_json[player_id]['player_name'] = player_name +2334 rebuilt_json[player_id]['home_away'] = home_away +2335 rebuilt_json[player_id]['defensive_TFL'] = player_stat +2336 +2337 elif stat['name'] == "QB HUR": # defensive_QB HUR +2338 for i in stat['athletes']: +2339 player_id = int(i['id']) +2340 player_name = i['name'] +2341 player_stat = int(i['stat']) +2342 +2343 if rebuilt_json.get(player_id) == None: +2344 rebuilt_json[player_id] = {} +2345 +2346 rebuilt_json[player_id]['game_id'] = game_id +2347 rebuilt_json[player_id]['team_name'] = team_name +2348 rebuilt_json[player_id]['team_confrence'] = team_confrence +2349 rebuilt_json[player_id]['player_id'] = player_id +2350 rebuilt_json[player_id]['player_name'] = player_name +2351 rebuilt_json[player_id]['home_away'] = home_away +2352 rebuilt_json[player_id]['defensive_QB HUR'] = player_stat +2353 +2354 elif stat['name'] == "SACKS": # defensive_SACKS +2355 for i in stat['athletes']: +2356 player_id = int(i['id']) +2357 player_name = i['name'] +2358 player_stat = float(i['stat']) +2359 +2360 if rebuilt_json.get(player_id) == None: +2361 rebuilt_json[player_id] = {} +2362 +2363 rebuilt_json[player_id]['game_id'] = game_id +2364 rebuilt_json[player_id]['team_name'] = team_name +2365 rebuilt_json[player_id]['team_confrence'] = team_confrence +2366 rebuilt_json[player_id]['player_id'] = player_id +2367 rebuilt_json[player_id]['player_name'] = player_name +2368 rebuilt_json[player_id]['home_away'] = home_away +2369 rebuilt_json[player_id]['defensive_SACKS'] = player_stat +2370 +2371 elif stat['name'] == "PD": # defensive_PD +2372 for i in stat['athletes']: +2373 player_id = int(i['id']) +2374 player_name = i['name'] +2375 player_stat = int(i['stat']) +2376 +2377 if rebuilt_json.get(player_id) == None: +2378 rebuilt_json[player_id] = {} +2379 +2380 rebuilt_json[player_id]['game_id'] = game_id +2381 rebuilt_json[player_id]['team_name'] = team_name +2382 rebuilt_json[player_id]['team_confrence'] = team_confrence +2383 rebuilt_json[player_id]['player_id'] = player_id +2384 rebuilt_json[player_id]['player_name'] = player_name +2385 rebuilt_json[player_id]['home_away'] = home_away +2386 rebuilt_json[player_id]['defensive_PD'] = player_stat +2387 +2388 elif stat['name'] == "TD": # defensive_TD +2389 for i in stat['athletes']: +2390 player_id = int(i['id']) +2391 player_name = i['name'] +2392 player_stat = int(i['stat']) +2393 +2394 if rebuilt_json.get(player_id) == None: +2395 rebuilt_json[player_id] = {} +2396 +2397 rebuilt_json[player_id]['game_id'] = game_id +2398 rebuilt_json[player_id]['team_name'] = team_name +2399 rebuilt_json[player_id]['team_confrence'] = team_confrence +2400 rebuilt_json[player_id]['player_id'] = player_id +2401 rebuilt_json[player_id]['player_name'] = player_name +2402 rebuilt_json[player_id]['home_away'] = home_away +2403 rebuilt_json[player_id]['defensive_TD'] = player_stat +2404 +2405 else: +2406 raise IndexError( +2407 f"Unhandled stat: \t{stat['name']}") +2408 +2409 elif s_category['name'] == "interceptions": +2410 for stat in s_category['types']: +2411 if stat['name'] == "INT": # interceptions_INT +2412 for i in stat['athletes']: +2413 player_id = int(i['id']) +2414 player_name = i['name'] +2415 player_stat = int(i['stat']) +2416 +2417 if rebuilt_json.get(player_id) == None: +2418 rebuilt_json[player_id] = {} +2419 +2420 rebuilt_json[player_id]['game_id'] = game_id +2421 rebuilt_json[player_id]['team_name'] = team_name +2422 rebuilt_json[player_id]['team_confrence'] = team_confrence +2423 rebuilt_json[player_id]['player_id'] = player_id +2424 rebuilt_json[player_id]['player_name'] = player_name +2425 rebuilt_json[player_id]['home_away'] = home_away +2426 rebuilt_json[player_id]['interceptions_INT'] = player_stat +2427 +2428 elif stat['name'] == "YDS": # interceptions_YDS +2429 for i in stat['athletes']: +2430 player_id = int(i['id']) +2431 player_name = i['name'] +2432 player_stat = int(i['stat']) +2433 +2434 if rebuilt_json.get(player_id) == None: +2435 rebuilt_json[player_id] = {} +2436 +2437 rebuilt_json[player_id]['game_id'] = game_id +2438 rebuilt_json[player_id]['team_name'] = team_name +2439 rebuilt_json[player_id]['team_confrence'] = team_confrence +2440 rebuilt_json[player_id]['player_id'] = player_id +2441 rebuilt_json[player_id]['player_name'] = player_name +2442 rebuilt_json[player_id]['home_away'] = home_away +2443 rebuilt_json[player_id]['interceptions_YDS'] = player_stat +2444 +2445 elif stat['name'] == "TD": # interceptions_TD +2446 for i in stat['athletes']: +2447 player_id = int(i['id']) +2448 player_name = i['name'] +2449 player_stat = int(i['stat']) +2450 +2451 if rebuilt_json.get(player_id) == None: +2452 rebuilt_json[player_id] = {} +2453 +2454 rebuilt_json[player_id]['game_id'] = game_id +2455 rebuilt_json[player_id]['team_name'] = team_name +2456 rebuilt_json[player_id]['team_confrence'] = team_confrence +2457 rebuilt_json[player_id]['player_id'] = player_id +2458 rebuilt_json[player_id]['player_name'] = player_name +2459 rebuilt_json[player_id]['home_away'] = home_away +2460 rebuilt_json[player_id]['interceptions_TD'] = player_stat +2461 +2462 else: +2463 raise IndexError( +2464 f"Unhandled stat: \t{stat['name']}") +2465 +2466 elif s_category['name'] == "punting": +2467 for stat in s_category['types']: +2468 if stat['name'] == "NO": # punting_NO +2469 for i in stat['athletes']: +2470 player_id = int(i['id']) +2471 player_name = i['name'] +2472 player_stat = int(i['stat']) +2473 +2474 if rebuilt_json.get(player_id) == None: +2475 rebuilt_json[player_id] = {} +2476 +2477 rebuilt_json[player_id]['game_id'] = game_id +2478 rebuilt_json[player_id]['team_name'] = team_name +2479 rebuilt_json[player_id]['team_confrence'] = team_confrence +2480 rebuilt_json[player_id]['player_id'] = player_id +2481 rebuilt_json[player_id]['player_name'] = player_name +2482 rebuilt_json[player_id]['home_away'] = home_away +2483 rebuilt_json[player_id]['punting_NO'] = player_stat +2484 +2485 elif stat['name'] == "YDS": # punting_YDS +2486 for i in stat['athletes']: +2487 player_id = int(i['id']) +2488 player_name = i['name'] +2489 player_stat = int(i['stat']) +2490 +2491 if rebuilt_json.get(player_id) == None: +2492 rebuilt_json[player_id] = {} +2493 +2494 rebuilt_json[player_id]['game_id'] = game_id +2495 rebuilt_json[player_id]['team_name'] = team_name +2496 rebuilt_json[player_id]['team_confrence'] = team_confrence +2497 rebuilt_json[player_id]['player_id'] = player_id +2498 rebuilt_json[player_id]['player_name'] = player_name +2499 rebuilt_json[player_id]['home_away'] = home_away +2500 rebuilt_json[player_id]['punting_YDS'] = player_stat +2501 +2502 elif stat['name'] == "AVG": # punting_AVG +2503 for i in stat['athletes']: +2504 player_id = int(i['id']) +2505 player_name = i['name'] +2506 player_stat = float(i['stat']) +2507 +2508 if rebuilt_json.get(player_id) == None: +2509 rebuilt_json[player_id] = {} +2510 +2511 rebuilt_json[player_id]['game_id'] = game_id +2512 rebuilt_json[player_id]['team_name'] = team_name +2513 rebuilt_json[player_id]['team_confrence'] = team_confrence +2514 rebuilt_json[player_id]['player_id'] = player_id +2515 rebuilt_json[player_id]['player_name'] = player_name +2516 rebuilt_json[player_id]['home_away'] = home_away +2517 rebuilt_json[player_id]['punting_AVG'] = player_stat +2518 +2519 elif stat['name'] == "TB": # punting_TB +2520 for i in stat['athletes']: +2521 player_id = int(i['id']) +2522 player_name = i['name'] +2523 player_stat = int(i['stat']) +2524 +2525 if rebuilt_json.get(player_id) == None: +2526 rebuilt_json[player_id] = {} +2527 +2528 rebuilt_json[player_id]['game_id'] = game_id +2529 rebuilt_json[player_id]['team_name'] = team_name +2530 rebuilt_json[player_id]['team_confrence'] = team_confrence +2531 rebuilt_json[player_id]['player_id'] = player_id +2532 rebuilt_json[player_id]['player_name'] = player_name +2533 rebuilt_json[player_id]['home_away'] = home_away +2534 rebuilt_json[player_id]['punting_TB'] = player_stat +2535 +2536 elif stat['name'] == "In 20": # punting_In 20 +2537 for i in stat['athletes']: +2538 player_id = int(i['id']) +2539 player_name = i['name'] +2540 player_stat = int(i['stat']) +2541 +2542 if rebuilt_json.get(player_id) == None: +2543 rebuilt_json[player_id] = {} +2544 +2545 rebuilt_json[player_id]['game_id'] = game_id +2546 rebuilt_json[player_id]['team_name'] = team_name +2547 rebuilt_json[player_id]['team_confrence'] = team_confrence +2548 rebuilt_json[player_id]['player_id'] = player_id +2549 rebuilt_json[player_id]['player_name'] = player_name +2550 rebuilt_json[player_id]['home_away'] = home_away +2551 rebuilt_json[player_id]['punting_In 20'] = player_stat +2552 +2553 elif stat['name'] == "LONG": # punting_LONG +2554 for i in stat['athletes']: +2555 player_id = int(i['id']) +2556 player_name = i['name'] +2557 player_stat = int(i['stat']) +2558 +2559 if rebuilt_json.get(player_id) == None: +2560 rebuilt_json[player_id] = {} +2561 +2562 rebuilt_json[player_id]['game_id'] = game_id +2563 rebuilt_json[player_id]['team_name'] = team_name +2564 rebuilt_json[player_id]['team_confrence'] = team_confrence +2565 rebuilt_json[player_id]['player_id'] = player_id +2566 rebuilt_json[player_id]['player_name'] = player_name +2567 rebuilt_json[player_id]['home_away'] = home_away +2568 rebuilt_json[player_id]['punting_LONG'] = player_stat +2569 +2570 else: +2571 raise IndexError( +2572 f"Unhandled stat: \t{stat['name']}") +2573 +2574 elif s_category['name'] == "kicking": +2575 for stat in s_category['types']: +2576 if stat['name'] == "FG": # kicking_FG +2577 for i in stat['athletes']: +2578 player_id = int(i['id']) +2579 player_name = i['name'] +2580 player_stat = i['stat'] +2581 +2582 if rebuilt_json.get(player_id) == None: +2583 rebuilt_json[player_id] = {} +2584 +2585 rebuilt_json[player_id]['game_id'] = game_id +2586 rebuilt_json[player_id]['team_name'] = team_name +2587 rebuilt_json[player_id]['team_confrence'] = team_confrence +2588 rebuilt_json[player_id]['player_id'] = player_id +2589 rebuilt_json[player_id]['player_name'] = player_name +2590 rebuilt_json[player_id]['home_away'] = home_away +2591 rebuilt_json[player_id]['kicking_FG'] = player_stat +2592 +2593 elif stat['name'] == "TOT": # kicking_FG, special case +2594 for i in stat['athletes']: +2595 player_id = int(i['id']) +2596 player_name = i['name'] +2597 player_stat = i['stat'] +2598 +2599 if rebuilt_json.get(player_id) == None: +2600 rebuilt_json[player_id] = {} +2601 +2602 rebuilt_json[player_id]['game_id'] = game_id +2603 rebuilt_json[player_id]['team_name'] = team_name +2604 rebuilt_json[player_id]['team_confrence'] = team_confrence +2605 rebuilt_json[player_id]['player_id'] = player_id +2606 rebuilt_json[player_id]['player_name'] = player_name +2607 rebuilt_json[player_id]['home_away'] = home_away +2608 rebuilt_json[player_id]['kicking_FG'] = player_stat +2609 +2610 elif stat['name'] == "PCT": # kicking_PCT +2611 for i in stat['athletes']: +2612 player_id = int(i['id']) +2613 player_name = i['name'] +2614 player_stat = float(i['stat']) +2615 +2616 if rebuilt_json.get(player_id) == None: +2617 rebuilt_json[player_id] = {} +2618 +2619 rebuilt_json[player_id]['game_id'] = game_id +2620 rebuilt_json[player_id]['team_name'] = team_name +2621 rebuilt_json[player_id]['team_confrence'] = team_confrence +2622 rebuilt_json[player_id]['player_id'] = player_id +2623 rebuilt_json[player_id]['player_name'] = player_name +2624 rebuilt_json[player_id]['home_away'] = home_away +2625 rebuilt_json[player_id]['kicking_PCT'] = player_stat +2626 +2627 elif stat['name'] == "LONG": # kicking_LONG +2628 for i in stat['athletes']: +2629 player_id = int(i['id']) +2630 player_name = i['name'] +2631 player_stat = int(i['stat']) +2632 +2633 if rebuilt_json.get(player_id) == None: +2634 rebuilt_json[player_id] = {} +2635 +2636 rebuilt_json[player_id]['game_id'] = game_id +2637 rebuilt_json[player_id]['team_name'] = team_name +2638 rebuilt_json[player_id]['team_confrence'] = team_confrence +2639 rebuilt_json[player_id]['player_id'] = player_id +2640 rebuilt_json[player_id]['player_name'] = player_name +2641 rebuilt_json[player_id]['home_away'] = home_away +2642 rebuilt_json[player_id]['kicking_LONG'] = player_stat +2643 +2644 elif stat['name'] == "XP": # kicking_XP +2645 for i in stat['athletes']: +2646 player_id = int(i['id']) +2647 player_name = i['name'] +2648 player_stat = i['stat'] +2649 +2650 if rebuilt_json.get(player_id) == None: +2651 rebuilt_json[player_id] = {} +2652 +2653 rebuilt_json[player_id]['game_id'] = game_id +2654 rebuilt_json[player_id]['team_name'] = team_name +2655 rebuilt_json[player_id]['team_confrence'] = team_confrence +2656 rebuilt_json[player_id]['player_id'] = player_id +2657 rebuilt_json[player_id]['player_name'] = player_name +2658 rebuilt_json[player_id]['home_away'] = home_away +2659 rebuilt_json[player_id]['kicking_XP'] = player_stat +2660 +2661 elif stat['name'] == "PTS": # kicking_PTS +2662 for i in stat['athletes']: +2663 player_id = int(i['id']) +2664 player_name = i['name'] +2665 player_stat = int(i['stat']) +2666 +2667 if rebuilt_json.get(player_id) == None: +2668 rebuilt_json[player_id] = {} +2669 +2670 rebuilt_json[player_id]['game_id'] = game_id +2671 rebuilt_json[player_id]['team_name'] = team_name +2672 rebuilt_json[player_id]['team_confrence'] = team_confrence +2673 rebuilt_json[player_id]['player_id'] = player_id +2674 rebuilt_json[player_id]['player_name'] = player_name +2675 rebuilt_json[player_id]['home_away'] = home_away +2676 rebuilt_json[player_id]['kicking_PTS'] = player_stat +2677 +2678 else: +2679 raise IndexError( +2680 f"Unhandled stat: \t{stat['name']}") +2681 +2682 elif s_category['name'] == "kickReturns": +2683 for stat in s_category['types']: +2684 if stat['name'] == "NO": # kickReturns_NO +2685 for i in stat['athletes']: +2686 player_id = int(i['id']) +2687 player_name = i['name'] +2688 player_stat = int(i['stat']) +2689 +2690 if rebuilt_json.get(player_id) == None: +2691 rebuilt_json[player_id] = {} +2692 +2693 rebuilt_json[player_id]['game_id'] = game_id +2694 rebuilt_json[player_id]['team_name'] = team_name +2695 rebuilt_json[player_id]['team_confrence'] = team_confrence +2696 rebuilt_json[player_id]['player_id'] = player_id +2697 rebuilt_json[player_id]['player_name'] = player_name +2698 rebuilt_json[player_id]['home_away'] = home_away +2699 rebuilt_json[player_id]['kickReturns_NO'] = player_stat +2700 +2701 elif stat['name'] == "YDS": # kickReturns_YDS +2702 for i in stat['athletes']: +2703 player_id = int(i['id']) +2704 player_name = i['name'] +2705 player_stat = int(i['stat']) +2706 +2707 if rebuilt_json.get(player_id) == None: +2708 rebuilt_json[player_id] = {} +2709 +2710 rebuilt_json[player_id]['game_id'] = game_id +2711 rebuilt_json[player_id]['team_name'] = team_name +2712 rebuilt_json[player_id]['team_confrence'] = team_confrence +2713 rebuilt_json[player_id]['player_id'] = player_id +2714 rebuilt_json[player_id]['player_name'] = player_name +2715 rebuilt_json[player_id]['home_away'] = home_away +2716 rebuilt_json[player_id]['kickReturns_YDS'] = player_stat +2717 +2718 elif stat['name'] == "AVG": # kickReturns_AVG +2719 for i in stat['athletes']: +2720 player_id = int(i['id']) +2721 player_name = i['name'] +2722 player_stat = float(i['stat']) +2723 +2724 if rebuilt_json.get(player_id) == None: +2725 rebuilt_json[player_id] = {} +2726 +2727 rebuilt_json[player_id]['game_id'] = game_id +2728 rebuilt_json[player_id]['team_name'] = team_name +2729 rebuilt_json[player_id]['team_confrence'] = team_confrence +2730 rebuilt_json[player_id]['player_id'] = player_id +2731 rebuilt_json[player_id]['player_name'] = player_name +2732 rebuilt_json[player_id]['home_away'] = home_away +2733 rebuilt_json[player_id]['kickReturns_AVG'] = player_stat +2734 +2735 elif stat['name'] == "TD": # kickReturns_TD +2736 for i in stat['athletes']: +2737 player_id = int(i['id']) +2738 player_name = i['name'] +2739 player_stat = int(i['stat']) +2740 +2741 if rebuilt_json.get(player_id) == None: +2742 rebuilt_json[player_id] = {} +2743 +2744 rebuilt_json[player_id]['game_id'] = game_id +2745 rebuilt_json[player_id]['team_name'] = team_name +2746 rebuilt_json[player_id]['team_confrence'] = team_confrence +2747 rebuilt_json[player_id]['player_id'] = player_id +2748 rebuilt_json[player_id]['player_name'] = player_name +2749 rebuilt_json[player_id]['home_away'] = home_away +2750 rebuilt_json[player_id]['kickReturns_TD'] = player_stat +2751 +2752 elif stat['name'] == "LONG": # kickReturns_LONG +2753 for i in stat['athletes']: +2754 player_id = int(i['id']) +2755 player_name = i['name'] +2756 player_stat = int(i['stat']) +2757 +2758 if rebuilt_json.get(player_id) == None: +2759 rebuilt_json[player_id] = {} +2760 +2761 rebuilt_json[player_id]['game_id'] = game_id +2762 rebuilt_json[player_id]['team_name'] = team_name +2763 rebuilt_json[player_id]['team_confrence'] = team_confrence +2764 rebuilt_json[player_id]['player_id'] = player_id +2765 rebuilt_json[player_id]['player_name'] = player_name +2766 rebuilt_json[player_id]['home_away'] = home_away +2767 rebuilt_json[player_id]['kickReturns_LONG'] = player_stat +2768 +2769 else: +2770 raise IndexError( +2771 f"Unhandled stat: \t{stat['name']}") +2772 +2773 elif s_category['name'] == "puntReturns": +2774 for stat in s_category['types']: +2775 if stat['name'] == "NO": # puntReturns_NO +2776 for i in stat['athletes']: +2777 player_id = int(i['id']) +2778 player_name = i['name'] +2779 player_stat = int(i['stat']) +2780 +2781 if rebuilt_json.get(player_id) == None: +2782 rebuilt_json[player_id] = {} +2783 +2784 rebuilt_json[player_id]['game_id'] = game_id +2785 rebuilt_json[player_id]['team_name'] = team_name +2786 rebuilt_json[player_id]['team_confrence'] = team_confrence +2787 rebuilt_json[player_id]['player_id'] = player_id +2788 rebuilt_json[player_id]['player_name'] = player_name +2789 rebuilt_json[player_id]['home_away'] = home_away +2790 rebuilt_json[player_id]['puntReturns_NO'] = player_stat +2791 +2792 elif stat['name'] == "YDS": # puntReturns_YDS +2793 for i in stat['athletes']: +2794 player_id = int(i['id']) +2795 player_name = i['name'] +2796 player_stat = int(i['stat']) +2797 +2798 if rebuilt_json.get(player_id) == None: +2799 rebuilt_json[player_id] = {} +2800 +2801 rebuilt_json[player_id]['game_id'] = game_id +2802 rebuilt_json[player_id]['team_name'] = team_name +2803 rebuilt_json[player_id]['team_confrence'] = team_confrence +2804 rebuilt_json[player_id]['player_id'] = player_id +2805 rebuilt_json[player_id]['player_name'] = player_name +2806 rebuilt_json[player_id]['home_away'] = home_away +2807 rebuilt_json[player_id]['puntReturns_YDS'] = player_stat +2808 +2809 elif stat['name'] == "AVG": # puntReturns_AVG +2810 for i in stat['athletes']: +2811 player_id = int(i['id']) +2812 player_name = i['name'] +2813 player_stat = float(i['stat']) +2814 +2815 if rebuilt_json.get(player_id) == None: +2816 rebuilt_json[player_id] = {} +2817 +2818 rebuilt_json[player_id]['game_id'] = game_id +2819 rebuilt_json[player_id]['team_name'] = team_name +2820 rebuilt_json[player_id]['team_confrence'] = team_confrence +2821 rebuilt_json[player_id]['player_id'] = player_id +2822 rebuilt_json[player_id]['player_name'] = player_name +2823 rebuilt_json[player_id]['home_away'] = home_away +2824 rebuilt_json[player_id]['puntReturns_AVG'] = player_stat +2825 +2826 elif stat['name'] == "TD": # puntReturns_TD +2827 for i in stat['athletes']: +2828 player_id = int(i['id']) +2829 player_name = i['name'] +2830 player_stat = int(i['stat']) +2831 +2832 if rebuilt_json.get(player_id) == None: +2833 rebuilt_json[player_id] = {} +2834 +2835 rebuilt_json[player_id]['game_id'] = game_id +2836 rebuilt_json[player_id]['team_name'] = team_name +2837 rebuilt_json[player_id]['team_confrence'] = team_confrence +2838 rebuilt_json[player_id]['player_id'] = player_id +2839 rebuilt_json[player_id]['player_name'] = player_name +2840 rebuilt_json[player_id]['home_away'] = home_away +2841 rebuilt_json[player_id]['puntReturns_TD'] = player_stat +2842 +2843 elif stat['name'] == "LONG": # puntReturns_LONG +2844 for i in stat['athletes']: +2845 player_id = int(i['id']) +2846 player_name = i['name'] +2847 player_stat = int(i['stat']) +2848 +2849 if rebuilt_json.get(player_id) == None: +2850 rebuilt_json[player_id] = {} +2851 +2852 rebuilt_json[player_id]['game_id'] = game_id +2853 rebuilt_json[player_id]['team_name'] = team_name +2854 rebuilt_json[player_id]['team_confrence'] = team_confrence +2855 rebuilt_json[player_id]['player_id'] = player_id +2856 rebuilt_json[player_id]['player_name'] = player_name +2857 rebuilt_json[player_id]['home_away'] = home_away +2858 rebuilt_json[player_id]['puntReturns_LONG'] = player_stat +2859 +2860 else: +2861 raise IndexError( +2862 f"Unhandled stat: \t{stat['name']}") +2863 +2864 else: +2865 raise IndexError( +2866 f"Unhandled stat category: \t{s_category['name']}" +2867 ) +2868 +2869 for key, value in tqdm(rebuilt_json.items()): +2870 # print(key) +2871 +2872 # print(value) +2873 game_id = value['game_id'] +2874 team_name = value['team_name'] +2875 team_confrence = value['team_confrence'] +2876 player_id = value['player_id'] +2877 player_name = value['player_name'] +2878 home_away = value['home_away'] +2879 +2880 row_df = pd.DataFrame( +2881 { +2882 "game_id": game_id, +2883 "team_name": team_name, +2884 "team_confrence": team_confrence, +2885 "player_id": player_id, +2886 "player_name": player_name, +2887 "home_away": home_away +2888 }, +2889 index=[0] +2890 ) +2891 # Passing +2892 if value.get('passing_C/ATT') != None: +2893 row_df['passing_C/ATT'] = value['passing_C/ATT'] +2894 +2895 if value.get('passing_YDS') != None: +2896 row_df['passing_YDS'] = value['passing_YDS'] +2897 +2898 if value.get('passing_AVG') != None: +2899 row_df['passing_AVG'] = value['passing_AVG'] +2900 +2901 if value.get('passing_TD') != None: +2902 row_df['passing_TD'] = value['passing_TD'] +2903 +2904 if value.get('passing_INT') != None: +2905 row_df['passing_INT'] = value['passing_INT'] +2906 +2907 if value.get('passing_QBR') != None: +2908 row_df['passing_QBR'] = value['passing_QBR'] +2909 +2910 # Rushing +2911 if value.get('rushing_CAR') != None: +2912 row_df['rushing_CAR'] = value['rushing_CAR'] +2913 +2914 if value.get('rushing_YDS') != None: +2915 row_df['rushing_YDS'] = value['rushing_YDS'] +2916 +2917 if value.get('rushing_AVG') != None: +2918 row_df['rushing_AVG'] = value['rushing_AVG'] +2919 +2920 if value.get('rushing_TD') != None: +2921 row_df['rushing_TD'] = value['rushing_TD'] +2922 +2923 if value.get('rushing_LONG') != None: +2924 row_df['rushing_LONG'] = value['rushing_LONG'] +2925 +2926 # Receiving +2927 if value.get('receiving_REC') != None: +2928 row_df['receiving_REC'] = value['receiving_REC'] +2929 +2930 if value.get('receiving_YDS') != None: +2931 row_df['receiving_YDS'] = value['receiving_YDS'] +2932 +2933 if value.get('receiving_AVG') != None: +2934 row_df['receiving_AVG'] = value['receiving_AVG'] +2935 +2936 if value.get('receiving_TD') != None: +2937 row_df['receiving_TD'] = value['receiving_TD'] +2938 +2939 if value.get('receiving_LONG') != None: +2940 row_df['receiving_LONG'] = value['receiving_LONG'] +2941 +2942 # Fumbles +2943 if value.get('fumbles_FUM') != None: +2944 row_df['fumbles_FUM'] = value['fumbles_FUM'] +2945 +2946 if value.get('fumbles_LOST') != None: +2947 row_df['fumbles_LOST'] = value['fumbles_LOST'] +2948 +2949 if value.get('fumbles_REC') != None: +2950 row_df['fumbles_REC'] = value['fumbles_REC'] +2951 +2952 # Defense +2953 if value.get('defensive_TOT') != None: +2954 row_df['defensive_TOT'] = value['defensive_TOT'] +2955 +2956 if value.get('defensive_SOLO') != None: +2957 row_df['defensive_SOLO'] = value['defensive_SOLO'] +2958 +2959 if value.get('defensive_TFL') != None: +2960 row_df['defensive_TFL'] = value['defensive_TFL'] +2961 +2962 if value.get('defensive_QB HUR') != None: +2963 row_df['defensive_QB HUR'] = value['defensive_QB HUR'] +2964 +2965 if value.get('defensive_SACKS') != None: +2966 row_df['defensive_SACKS'] = value['defensive_SACKS'] +2967 +2968 if value.get('defensive_PD') != None: +2969 row_df['defensive_PD'] = value['defensive_PD'] +2970 +2971 if value.get('defensive_TD') != None: +2972 row_df['defensive_TD'] = value['defensive_TD'] +2973 +2974 # interceptions +2975 if value.get('interceptions_INT') != None: +2976 row_df['interceptions_INT'] = value['interceptions_INT'] +2977 +2978 if value.get('interceptions_YDS') != None: +2979 row_df['interceptions_YDS'] = value['interceptions_YDS'] +2980 +2981 if value.get('interceptions_TD') != None: +2982 row_df['interceptions_TD'] = value['interceptions_TD'] +2983 +2984 # punting +2985 if value.get('punting_NO') != None: +2986 row_df['punting_NO'] = value['punting_NO'] +2987 +2988 if value.get('punting_YDS') != None: +2989 row_df['punting_YDS'] = value['punting_YDS'] +2990 +2991 if value.get('punting_AVG') != None: +2992 row_df['punting_AVG'] = value['punting_AVG'] +2993 +2994 if value.get('punting_TB') != None: +2995 row_df['punting_TB'] = value['punting_TB'] +2996 +2997 if value.get('punting_In 20') != None: +2998 row_df['punting_In 20'] = value['punting_In 20'] +2999 +3000 if value.get('punting_LONG') != None: +3001 row_df['punting_LONG'] = value['punting_LONG'] +3002 +3003 # kicking +3004 if value.get('kicking_FG') != None: +3005 row_df['kicking_FG'] = value['kicking_FG'] +3006 +3007 if value.get('kicking_PCT') != None: +3008 row_df['kicking_PCT'] = value['kicking_PCT'] +3009 +3010 if value.get('kicking_LONG') != None: +3011 row_df['kicking_LONG'] = value['kicking_LONG'] +3012 +3013 if value.get('kicking_XP') != None: +3014 row_df['kicking_XP'] = value['kicking_XP'] +3015 +3016 if value.get('kicking_PTS') != None: +3017 row_df['kicking_PTS'] = value['kicking_PTS'] +3018 +3019 # kickReturns +3020 if value.get('kickReturns_NO') != None: +3021 row_df['kickReturns_NO'] = value['kickReturns_NO'] +3022 +3023 if value.get('kickReturns_YDS') != None: +3024 row_df['kickReturns_YDS'] = value['kickReturns_YDS'] +3025 +3026 if value.get('kickReturns_AVG') != None: +3027 row_df['kickReturns_AVG'] = value['kickReturns_AVG'] +3028 +3029 if value.get('kickReturns_TD') != None: +3030 row_df['kickReturns_TD'] = value['kickReturns_TD'] +3031 +3032 if value.get('kickReturns_LONG') != None: +3033 row_df['kickReturns_LONG'] = value['kickReturns_LONG'] +3034 +3035 # puntReturns +3036 if value.get('puntReturns_NO') != None: +3037 row_df['puntReturns_NO'] = value['puntReturns_NO'] +3038 +3039 if value.get('puntReturns_YDS') != None: +3040 row_df['puntReturns_YDS'] = value['puntReturns_YDS'] +3041 +3042 if value.get('puntReturns_AVG') != None: +3043 row_df['puntReturns_AVG'] = value['puntReturns_AVG'] +3044 +3045 if value.get('puntReturns_TD') != None: +3046 row_df['puntReturns_TD'] = value['puntReturns_TD'] +3047 +3048 if value.get('puntReturns_LONG') != None: +3049 row_df['puntReturns_LONG'] = value['puntReturns_LONG'] +3050 +3051 cfb_games_df = pd.concat([cfb_games_df, row_df], ignore_index=True) +3052 del row_df +3053 +3054 cfb_games_df[['passing_COMP', 'passing_ATT'] +3055 ] = cfb_games_df['passing_C/ATT'].str.split('/', expand=True) +3056 +3057 cfb_games_df[['kicking_FGM', 'kicking_FGA'] +3058 ] = cfb_games_df['kicking_FG'].str.split('/', expand=True) +3059 cfb_games_df[['kicking_XPM', 'kicking_XPA'] +3060 ] = cfb_games_df['kicking_XP'].str.split('/', expand=True) +3061 +3062 cfb_games_df = cfb_games_df.fillna(0) +3063 +3064 cfb_games_df = cfb_games_df.astype({ +3065 "passing_COMP": "int", +3066 "passing_ATT": "int", +3067 "kicking_FGM": "int", +3068 "kicking_FGA": "int", +3069 "kicking_XPM": "int", +3070 "kicking_XPA": "int" +3071 }) +3072 # print(cfb_games_df.columns) +3073 cfb_games_df['season'] = season +3074 +3075 if filter_by_stat_category == False: +3076 cfb_games_df = cfb_games_df.reindex(columns=stat_columns) +3077 +3078 elif filter_by_stat_category == True and stat_category == "passing": +3079 cfb_games_df = cfb_games_df[[ +3080 'season', +3081 'game_id', +3082 'team_name', +3083 'team_confrence', +3084 'player_id', +3085 'player_name', +3086 'home_away', +3087 # PASS +3088 'passing_C/ATT', +3089 'passing_COMP', +3090 'passing_ATT', +3091 'passing_YDS', +3092 'passing_AVG', +3093 'passing_TD', +3094 'passing_INT', +3095 'passing_QBR' +3096 ]] +3097 +3098 elif filter_by_stat_category == True and stat_category == "rushing": +3099 cfb_games_df = cfb_games_df[[ +3100 'season', +3101 'game_id', +3102 'team_name', +3103 'team_confrence', +3104 'player_id', +3105 'player_name', +3106 'home_away', +3107 # RUSH +3108 'rushing_CAR', +3109 'rushing_YDS', +3110 'rushing_AVG', +3111 'rushing_TD', +3112 'rushing_LONG', +3113 ]] +3114 +3115 elif filter_by_stat_category == True and stat_category == "receiving": +3116 cfb_games_df = cfb_games_df[[ +3117 'season', +3118 'game_id', +3119 'team_name', +3120 'team_confrence', +3121 'player_id', +3122 'player_name', +3123 'home_away', +3124 # REC +3125 'receiving_REC', +3126 'receiving_YDS', +3127 'receiving_AVG', +3128 'receiving_TD', +3129 'receiving_LONG' +3130 ]] +3131 +3132 elif filter_by_stat_category == True and stat_category == "fumbles": +3133 cfb_games_df = cfb_games_df[[ +3134 'season', +3135 'game_id', +3136 'team_name', +3137 'team_confrence', +3138 'player_id', +3139 'player_name', +3140 'home_away', +3141 # FUM +3142 'fumbles_FUM', +3143 'fumbles_LOST', +3144 'fumbles_REC' +3145 ]] +3146 +3147 elif filter_by_stat_category == True and stat_category == "defensive": +3148 cfb_games_df = cfb_games_df[[ +3149 'season', +3150 'game_id', +3151 'team_name', +3152 'team_confrence', +3153 'player_id', +3154 'player_name', +3155 'home_away', +3156 # DEFENSE +3157 'defensive_TOT', +3158 'defensive_SOLO', +3159 'defensive_TFL', +3160 'defensive_QB HUR', +3161 'defensive_SACKS', +3162 'defensive_PD', +3163 'defensive_TD' +3164 ]] +3165 +3166 elif filter_by_stat_category == True and stat_category == "interceptions": +3167 cfb_games_df = cfb_games_df[[ +3168 'season', +3169 'game_id', +3170 'team_name', +3171 'team_confrence', +3172 'player_id', +3173 'player_name', +3174 'home_away', +3175 # INT +3176 'interceptions_INT', +3177 'interceptions_YDS', +3178 'interceptions_TD', +3179 ]] +3180 +3181 elif filter_by_stat_category == True and stat_category == "punting": +3182 cfb_games_df = cfb_games_df[[ +3183 'season', +3184 'game_id', +3185 'team_name', +3186 'team_confrence', +3187 'player_id', +3188 'player_name', +3189 'home_away', +3190 # PUNT +3191 'punting_NO', +3192 'punting_YDS', +3193 'punting_AVG', +3194 'punting_TB', +3195 'punting_In 20', +3196 'punting_LONG' +3197 ]] +3198 +3199 elif filter_by_stat_category == True and stat_category == "kicking": +3200 cfb_games_df = cfb_games_df[[ +3201 'season', +3202 'game_id', +3203 'team_name', +3204 'team_confrence', +3205 'player_id', +3206 'player_name', +3207 'home_away', +3208 # KICK +3209 'kicking_FG', +3210 'kicking_FGM', +3211 'kicking_FGA', +3212 'kicking_PCT', +3213 'kicking_LONG', +3214 'kicking_XP', +3215 'kicking_XPM', +3216 'kicking_XPA', +3217 'kicking_PTS' +3218 ]] +3219 +3220 elif filter_by_stat_category == True and stat_category == "kickReturns": +3221 cfb_games_df = cfb_games_df[[ +3222 'season', +3223 'game_id', +3224 'team_name', +3225 'team_confrence', +3226 'player_id', +3227 'player_name', +3228 'home_away', +3229 # KR +3230 'kickReturns_NO', +3231 'kickReturns_YDS', +3232 'kickReturns_AVG', +3233 'kickReturns_TD', +3234 'kickReturns_LONG' +3235 ]] +3236 +3237 elif filter_by_stat_category == True and stat_category == "puntReturns": +3238 cfb_games_df = cfb_games_df[[ +3239 'season', +3240 'game_id', +3241 'team_name', +3242 'team_confrence', +3243 'player_id', +3244 'player_name', +3245 'home_away', +3246 # KR +3247 'puntReturns_NO', +3248 'puntReturns_YDS', +3249 'puntReturns_AVG', +3250 'puntReturns_TD', +3251 'puntReturns_LONG' +3252 ]] +3253 +3254 return cfb_games_df 3255 -3256 `api_key` (str, optional): -3257 Semi-optional argument. -3258 If `api_key` is null, this function will attempt to load a CFBD API key -3259 from the python environment, or from a file on this computer. -3260 If `api_key` is not null, this function will automatically assume that the -3261 inputted `api_key` is a valid CFBD API key. -3262 -3263 `api_key_dir` (str, optional): -3264 Optional argument. -3265 If `api_key` is set to am empty string, this variable is ignored. -3266 If `api_key_dir` is null, and `api_key` is null, -3267 this function will try to find a CFBD API key file in this user's home directory. -3268 If `api_key_dir` is set to a string, and `api_key` is null, -3269 this function will assume that `api_key_dir` is a directory, -3270 and will try to find a CFBD API key file in that directory. -3271 -3272 `return_as_dict` (bool, semi-optional): -3273 Semi-optional argument. -3274 If you want this function to return the data as a dictionary (read: JSON object), -3275 instead of a pandas `DataFrame` object, -3276 set `return_as_dict` to `True`. -3277 -3278 Usage -3279 ---------- -3280 ``` -3281 import time -3282 -3283 from cfbd_json_py.games import get_cfbd_player_advanced_game_stats -3284 -3285 -3286 cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. -3287 -3288 if cfbd_key != "tigersAreAwsome": -3289 print("Using the user's API key declared in this script for this example.") -3290 -3291 # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, -3292 # and the Oklahoma Sooners Football Program. -3293 print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.") -3294 json_data = get_cfbd_player_advanced_game_stats( -3295 api_key=cfbd_key, -3296 game_id=401135278 -3297 ) -3298 print(json_data) -3299 time.sleep(5) -3300 -3301 -3302 # You can also tell this function to just return the API call as -3303 # a Dictionary (read: JSON) object. -3304 print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") -3305 json_data = get_cfbd_player_advanced_game_stats( -3306 api_key=cfbd_key, -3307 game_id=401135278, -3308 return_as_dict=True +3256 +3257def get_cfbd_player_advanced_game_stats( +3258 game_id: int, +3259 api_key: str = None, +3260 api_key_dir: str = None, +3261 return_as_dict: bool = False): +3262 """ +3263 Retrives advanced game stats from the CFBD API. +3264 +3265 Parameters +3266 ---------- +3267 +3268 `api_key` (str, optional): +3269 Semi-optional argument. +3270 If `api_key` is null, this function will attempt to load a CFBD API key +3271 from the python environment, or from a file on this computer. +3272 If `api_key` is not null, this function will automatically assume that the +3273 inputted `api_key` is a valid CFBD API key. +3274 +3275 `api_key_dir` (str, optional): +3276 Optional argument. +3277 If `api_key` is set to am empty string, this variable is ignored. +3278 If `api_key_dir` is null, and `api_key` is null, +3279 this function will try to find a CFBD API key file in this user's home directory. +3280 If `api_key_dir` is set to a string, and `api_key` is null, +3281 this function will assume that `api_key_dir` is a directory, +3282 and will try to find a CFBD API key file in that directory. +3283 +3284 `return_as_dict` (bool, semi-optional): +3285 Semi-optional argument. +3286 If you want this function to return the data as a dictionary (read: JSON object), +3287 instead of a pandas `DataFrame` object, +3288 set `return_as_dict` to `True`. +3289 +3290 Usage +3291 ---------- +3292 ``` +3293 import time +3294 +3295 from cfbd_json_py.games import get_cfbd_player_advanced_game_stats +3296 +3297 +3298 cfbd_key = "tigersAreAwsome" # placeholder for your CFBD API Key. +3299 +3300 if cfbd_key != "tigersAreAwsome": +3301 print("Using the user's API key declared in this script for this example.") +3302 +3303 # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, +3304 # and the Oklahoma Sooners Football Program. +3305 print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.") +3306 json_data = get_cfbd_player_advanced_game_stats( +3307 api_key=cfbd_key, +3308 game_id=401135278 3309 ) 3310 print(json_data) -3311 -3312 else: -3313 # Alternatively, if the CFBD API key exists in this python environment, -3314 # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), -3315 # you could just call these functions directly, without setting the API key -3316 # in the script. -3317 print("Using the user's API key suposedly loaded into this python environment for this example.") -3318 -3319 # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, -3320 # and the Oklahoma Sooners Football Program. -3321 print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.") -3322 json_data = get_cfbd_player_advanced_game_stats( -3323 game_id=401135278 -3324 ) -3325 print(json_data) -3326 time.sleep(5) -3327 -3328 -3329 # You can also tell this function to just return the API call as -3330 # a Dictionary (read: JSON) object. -3331 print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") -3332 json_data = get_cfbd_player_advanced_game_stats( -3333 game_id=401135278, -3334 return_as_dict=True -3335 ) -3336 print(json_data) -3337 -3338 ``` -3339 Returns -3340 ---------- -3341 A pandas `DataFrame` object with college football game information, -3342 or (if `return_as_dict` is set to `True`) -3343 a dictionary object with college football game information. -3344 """ -3345 -3346 #now = datetime.now() -3347 usage_df = pd.DataFrame() -3348 ppa_df = pd.DataFrame() -3349 adv_stats_df = pd.DataFrame() -3350 row_df = pd.DataFrame() -3351 url = "https://api.collegefootballdata.com/game/box/advanced" -3352 -3353 ######################################################################################################################################################################################################## -3354 -3355 if api_key != None: -3356 real_api_key = api_key -3357 del api_key -3358 else: -3359 real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) -3360 -3361 if real_api_key == "tigersAreAwsome": -3362 raise ValueError( -3363 "You actually need to change `cfbd_key` to your CFBD API key.") -3364 elif "Bearer " in real_api_key: -3365 pass -3366 elif "Bearer" in real_api_key: -3367 real_api_key = real_api_key.replace('Bearer', 'Bearer ') -3368 else: -3369 real_api_key = "Bearer " + real_api_key -3370 -3371 # URL builder -3372 ######################################################################################################################################################################################################## -3373 -3374 # Required by API -3375 url += f"?gameId={game_id}" -3376 -3377 headers = { -3378 'Authorization': f'{real_api_key}', -3379 'accept': 'application/json' -3380 } -3381 -3382 response = requests.get(url, headers=headers) -3383 -3384 -3385 if response.status_code == 200: -3386 pass -3387 elif response.status_code == 401: -3388 raise ConnectionRefusedError( -3389 f'Could not connect. The connection was refused.\nHTTP Status Code 401.' -3390 ) -3391 else: -3392 raise ConnectionError( -3393 f'Could not connect.\nHTTP Status code {response.status_code}' -3394 ) -3395 -3396 json_data = response.json() -3397 -3398 if return_as_dict == True: -3399 return json_data -3400 -3401 home_team_name = json_data['gameInfo']['homeTeam'] -3402 home_points = json_data['gameInfo']['homePoints'] -3403 home_win_prob = json_data['gameInfo']['homeWinProb'] -3404 away_team_name = json_data['gameInfo']['awayTeam'] -3405 away_points = json_data['gameInfo']['awayPoints'] -3406 away_win_prob = json_data['gameInfo']['awayWinProb'] -3407 home_winner = json_data['gameInfo']['homeWinner'] -3408 game_excitement_score = json_data['gameInfo']['excitement'] -3409 -3410 -3411 # Parsing Usage -3412 print("Parsing player usage data.") -3413 for player in tqdm(json_data['players']['usage']): -3414 row_df = pd.DataFrame( -3415 { -3416 "game_id":game_id -3417 }, -3418 index=[0] -3419 ) -3420 row_df['player_name'] = player['player'] -3421 row_df['team'] = player['team'] -3422 row_df['position'] = player['position'] -3423 -3424 row_df['total_usage'] = player['total'] -3425 row_df['q1_usage'] = player['quarter1'] -3426 row_df['q2_usage'] = player['quarter2'] -3427 row_df['q3_usage'] = player['quarter3'] -3428 row_df['q4_usage'] = player['quarter4'] -3429 row_df['rushing_usage'] = player['rushing'] -3430 row_df['passing_usage'] = player['passing'] -3431 -3432 usage_df = pd.concat([usage_df,row_df],ignore_index=True) -3433 del row_df -3434 -3435 # Parsing PPA -3436 print("Parsing player PPA data.") -3437 for player in tqdm(json_data['players']['ppa']): -3438 row_df = pd.DataFrame( -3439 { -3440 "game_id":game_id -3441 }, -3442 index=[0] -3443 ) -3444 row_df['player_name'] = player['player'] -3445 row_df['team'] = player['team'] -3446 row_df['position'] = player['position'] -3447 -3448 row_df['average_ppa_total'] = player['average']['total'] -3449 row_df['average_ppa_q1'] = player['average']['quarter1'] -3450 row_df['average_ppa_q2'] = player['average']['quarter2'] -3451 row_df['average_ppa_q3'] = player['average']['quarter3'] -3452 row_df['average_ppa_q4'] = player['average']['quarter4'] -3453 row_df['average_ppa_rushing'] = player['average']['rushing'] -3454 row_df['average_ppa_passing'] = player['average']['passing'] -3455 -3456 row_df['cumulative_ppa_total'] = player['cumulative']['total'] -3457 row_df['cumulative_ppa_q1'] = player['cumulative']['quarter1'] -3458 row_df['cumulative_ppa_q2'] = player['cumulative']['quarter2'] -3459 row_df['cumulative_ppa_q3'] = player['cumulative']['quarter3'] -3460 row_df['cumulative_ppa_q4'] = player['cumulative']['quarter4'] -3461 row_df['cumulative_ppa_rushing'] = player['cumulative']['rushing'] -3462 row_df['cumulative_ppa_passing'] = player['cumulative']['passing'] -3463 -3464 ppa_df = pd.concat([ppa_df,row_df],ignore_index=True) -3465 -3466 # Join `usage_df` and `ppa_df` together -3467 adv_stats_df = pd.merge( -3468 left=usage_df, -3469 right=ppa_df, -3470 how="outer", -3471 on=["game_id","player_name","team","position"] -3472 ) -3473 -3474 # Add in these columns for completeness. -3475 -3476 adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"home_away"] = "home" -3477 adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"opponent"] = away_team_name -3478 -3479 adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"home_away"] = "away" -3480 adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"opponent"] = home_team_name -3481 -3482 adv_stats_df['home_team'] = home_team_name -3483 adv_stats_df['away_team'] = away_team_name -3484 -3485 adv_stats_df['home_win_prob'] = home_win_prob -3486 adv_stats_df['away_win_prob'] = away_win_prob +3311 time.sleep(5) +3312 +3313 +3314 # You can also tell this function to just return the API call as +3315 # a Dictionary (read: JSON) object. +3316 print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") +3317 json_data = get_cfbd_player_advanced_game_stats( +3318 api_key=cfbd_key, +3319 game_id=401135278, +3320 return_as_dict=True +3321 ) +3322 print(json_data) +3323 +3324 else: +3325 # Alternatively, if the CFBD API key exists in this python environment, +3326 # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(), +3327 # you could just call these functions directly, without setting the API key +3328 # in the script. +3329 print("Using the user's API key suposedly loaded into this python environment for this example.") +3330 +3331 # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, +3332 # and the Oklahoma Sooners Football Program. +3333 print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.") +3334 json_data = get_cfbd_player_advanced_game_stats( +3335 game_id=401135278 +3336 ) +3337 print(json_data) +3338 time.sleep(5) +3339 +3340 +3341 # You can also tell this function to just return the API call as +3342 # a Dictionary (read: JSON) object. +3343 print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.") +3344 json_data = get_cfbd_player_advanced_game_stats( +3345 game_id=401135278, +3346 return_as_dict=True +3347 ) +3348 print(json_data) +3349 +3350 ``` +3351 Returns +3352 ---------- +3353 A pandas `DataFrame` object with college football game information, +3354 or (if `return_as_dict` is set to `True`) +3355 a dictionary object with college football game information. +3356 """ +3357 +3358 #now = datetime.now() +3359 usage_df = pd.DataFrame() +3360 ppa_df = pd.DataFrame() +3361 adv_stats_df = pd.DataFrame() +3362 row_df = pd.DataFrame() +3363 url = "https://api.collegefootballdata.com/game/box/advanced" +3364 +3365 ######################################################################################################################################################################################################## +3366 +3367 if api_key != None: +3368 real_api_key = api_key +3369 del api_key +3370 else: +3371 real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) +3372 +3373 if real_api_key == "tigersAreAwsome": +3374 raise ValueError( +3375 "You actually need to change `cfbd_key` to your CFBD API key.") +3376 elif "Bearer " in real_api_key: +3377 pass +3378 elif "Bearer" in real_api_key: +3379 real_api_key = real_api_key.replace('Bearer', 'Bearer ') +3380 else: +3381 real_api_key = "Bearer " + real_api_key +3382 +3383 # URL builder +3384 ######################################################################################################################################################################################################## +3385 +3386 # Required by API +3387 url += f"?gameId={game_id}" +3388 +3389 headers = { +3390 'Authorization': f'{real_api_key}', +3391 'accept': 'application/json' +3392 } +3393 +3394 response = requests.get(url, headers=headers) +3395 +3396 +3397 if response.status_code == 200: +3398 pass +3399 elif response.status_code == 401: +3400 raise ConnectionRefusedError( +3401 f'Could not connect. The connection was refused.\nHTTP Status Code 401.' +3402 ) +3403 else: +3404 raise ConnectionError( +3405 f'Could not connect.\nHTTP Status code {response.status_code}' +3406 ) +3407 +3408 json_data = response.json() +3409 +3410 if return_as_dict == True: +3411 return json_data +3412 +3413 home_team_name = json_data['gameInfo']['homeTeam'] +3414 home_points = json_data['gameInfo']['homePoints'] +3415 home_win_prob = json_data['gameInfo']['homeWinProb'] +3416 away_team_name = json_data['gameInfo']['awayTeam'] +3417 away_points = json_data['gameInfo']['awayPoints'] +3418 away_win_prob = json_data['gameInfo']['awayWinProb'] +3419 home_winner = json_data['gameInfo']['homeWinner'] +3420 game_excitement_score = json_data['gameInfo']['excitement'] +3421 +3422 +3423 # Parsing Usage +3424 print("Parsing player usage data.") +3425 for player in tqdm(json_data['players']['usage']): +3426 row_df = pd.DataFrame( +3427 { +3428 "game_id":game_id +3429 }, +3430 index=[0] +3431 ) +3432 row_df['player_name'] = player['player'] +3433 row_df['team'] = player['team'] +3434 row_df['position'] = player['position'] +3435 +3436 row_df['total_usage'] = player['total'] +3437 row_df['q1_usage'] = player['quarter1'] +3438 row_df['q2_usage'] = player['quarter2'] +3439 row_df['q3_usage'] = player['quarter3'] +3440 row_df['q4_usage'] = player['quarter4'] +3441 row_df['rushing_usage'] = player['rushing'] +3442 row_df['passing_usage'] = player['passing'] +3443 +3444 usage_df = pd.concat([usage_df,row_df],ignore_index=True) +3445 del row_df +3446 +3447 # Parsing PPA +3448 print("Parsing player PPA data.") +3449 for player in tqdm(json_data['players']['ppa']): +3450 row_df = pd.DataFrame( +3451 { +3452 "game_id":game_id +3453 }, +3454 index=[0] +3455 ) +3456 row_df['player_name'] = player['player'] +3457 row_df['team'] = player['team'] +3458 row_df['position'] = player['position'] +3459 +3460 row_df['average_ppa_total'] = player['average']['total'] +3461 row_df['average_ppa_q1'] = player['average']['quarter1'] +3462 row_df['average_ppa_q2'] = player['average']['quarter2'] +3463 row_df['average_ppa_q3'] = player['average']['quarter3'] +3464 row_df['average_ppa_q4'] = player['average']['quarter4'] +3465 row_df['average_ppa_rushing'] = player['average']['rushing'] +3466 row_df['average_ppa_passing'] = player['average']['passing'] +3467 +3468 row_df['cumulative_ppa_total'] = player['cumulative']['total'] +3469 row_df['cumulative_ppa_q1'] = player['cumulative']['quarter1'] +3470 row_df['cumulative_ppa_q2'] = player['cumulative']['quarter2'] +3471 row_df['cumulative_ppa_q3'] = player['cumulative']['quarter3'] +3472 row_df['cumulative_ppa_q4'] = player['cumulative']['quarter4'] +3473 row_df['cumulative_ppa_rushing'] = player['cumulative']['rushing'] +3474 row_df['cumulative_ppa_passing'] = player['cumulative']['passing'] +3475 +3476 ppa_df = pd.concat([ppa_df,row_df],ignore_index=True) +3477 +3478 # Join `usage_df` and `ppa_df` together +3479 adv_stats_df = pd.merge( +3480 left=usage_df, +3481 right=ppa_df, +3482 how="outer", +3483 on=["game_id","player_name","team","position"] +3484 ) +3485 +3486 # Add in these columns for completeness. 3487 -3488 adv_stats_df['home_points'] = home_points -3489 adv_stats_df['away_points'] = away_points -3490 -3491 adv_stats_df['home_winner'] = home_winner -3492 adv_stats_df['game_excitement_score'] = game_excitement_score -3493 -3494 return adv_stats_df -3495 +3488 adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"home_away"] = "home" +3489 adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"opponent"] = away_team_name +3490 +3491 adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"home_away"] = "away" +3492 adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"opponent"] = home_team_name +3493 +3494 adv_stats_df['home_team'] = home_team_name +3495 adv_stats_df['away_team'] = away_team_name 3496 -3497#################################################################################################### -3498# Patreon Only Functions. -3499# No cacheing, because the entire point of these functions are to get people -3500# data ASAP, and right before kickoff. -3501#################################################################################################### +3497 adv_stats_df['home_win_prob'] = home_win_prob +3498 adv_stats_df['away_win_prob'] = away_win_prob +3499 +3500 adv_stats_df['home_points'] = home_points +3501 adv_stats_df['away_points'] = away_points 3502 -3503 -3504def get_cfbd_live_scoreboard( -3505 api_key: str = None, -3506 api_key_dir: str = None, -3507 ncaa_division: str = "fbs", -3508 conference: str = None): -3509 """ -3510 YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK! -3511 To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata -3512 -3513 -3514 """ +3503 adv_stats_df['home_winner'] = home_winner +3504 adv_stats_df['game_excitement_score'] = game_excitement_score +3505 +3506 return adv_stats_df +3507 +3508 +3509#################################################################################################### +3510# Patreon Only Functions. +3511# No cacheing, because the entire point of these functions are to get people +3512# data ASAP, and right before kickoff. +3513#################################################################################################### +3514 3515 -3516 raise NotImplementedError( -3517 'This function has yet to be implemented by this version.' -3518 ) -3519 -3520 -3521def get_cfbd_weather_info( -3522 api_key: str = None, -3523 api_key_dir: str = None, -3524 ncaa_division: str = "fbs", -3525 game_id: int = None, -3526 # `game_id` and/or `year` must be not null for this function to work. -3527 season: int = None, -3528 week: int = None, -3529 season_type: str = "regular", # "regular", "postseason", or "both" -3530 conference: str = None): -3531 """ -3532 YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK! -3533 To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata -3534 """ -3535 -3536 raise NotImplementedError( -3537 'This function has yet to be implemented by this version.' -3538 ) +3516def get_cfbd_live_scoreboard( +3517 api_key: str = None, +3518 api_key_dir: str = None, +3519 ncaa_division: str = "fbs", +3520 conference: str = None): +3521 """ +3522 YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK! +3523 To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata +3524 +3525 +3526 """ +3527 +3528 raise NotImplementedError( +3529 'This function has yet to be implemented by this version.' +3530 ) +3531 +3532 +3533def get_cfbd_weather_info( +3534 api_key: str = None, +3535 api_key_dir: str = None, +3536 ncaa_division: str = "fbs", +3537 game_id: int = None, +3538 # `game_id` and/or `year` must be not null for this function to work. +3539 season: int = None, +3540 week: int = None, +3541 season_type: str = "regular", # "regular", "postseason", or "both" +3542 conference: str = None): +3543 """ +3544 YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK! +3545 To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata +3546 """ +3547 +3548 raise NotImplementedError( +3549 'This function has yet to be implemented by this version.' +3550 )

@@ -3980,7 +3992,7 @@

368 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 369 "https://github.com/armstjc/cfbd-json-py/issues" 370 ) -371 elif season > now.year: +371 elif season > (now.year + 1): 372 raise ValueError(f"`season` cannot be greater than {season}.") 373 elif season < 1869: 374 raise ValueError(f"`season` cannot be less than 1869.") @@ -5035,7 +5047,7 @@

Returns

933 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 934 "https://github.com/armstjc/cfbd-json-py/issues" 935 ) -936 elif season > now.year: +936 elif season > (now.year + 1): 937 raise ValueError(f"`season` cannot be greater than {season}.") 938 elif season < 1869: 939 raise ValueError(f"`season` cannot be less than 1869.") @@ -5527,7 +5539,7 @@

Returns

1313 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 1314 "https://github.com/armstjc/cfbd-json-py/issues" 1315 ) -1316 elif season > now.year: +1316 elif season > (now.year + 1): 1317 raise ValueError(f"`season` cannot be greater than {season}.") 1318 elif season < 1869: 1319 raise ValueError(f"`season` cannot be less than 1869.") @@ -5952,9 +5964,9 @@

Returns

1438 ---------- 1439 `season` (int, mandatory): 1440 Required argument. -1441 Specifies the season you want CFB media information from. +1441 Specifies the season you want CFB player game stats from. 1442 This must be specified, otherwise this package, and by extension -1443 the CFBD API, will not accept the request to get CFB media information. +1443 the CFBD API, will not accept the request to get CFB player game stats. 1444 1445 `api_key` (str, optional): 1446 Semi-optional argument. @@ -5975,7 +5987,7 @@

Returns

1461 `season_type` (str, semi-optional): 1462 Semi-optional argument. 1463 By defualt, this will be set to "regular", for the CFB regular season. -1464 If you want CFB media information for non-regular season games, +1464 If you want CFB player game stats for non-regular season games, 1465 set `season_type` to "postseason". 1466 If `season_type` is set to anything but "regular" or "postseason", 1467 a `ValueError()` will be raised. @@ -5986,20 +5998,20 @@

Returns

1472 `week` (int, optional): 1473 Optional argument. 1474 If `week` is set to an integer, this function will attempt -1475 to load CFB media information from games in that season, and in that week. +1475 to load CFB player game stats from games in that season, and in that week. 1476 1477 `team` (str, optional): 1478 Optional argument. -1479 If you only want CFB media information for a team, +1479 If you only want CFB player game stats for a team, 1480 regardless if they are the home/away team, -1481 set `team` to the name of the team you want CFB media information from. +1481 set `team` to the name of the team you want CFB player game stats from. 1482 1483 `conference_abv` (str, optional): 1484 Optional argument. -1485 If you only want media information from games +1485 If you only want player game stats from games 1486 involving teams a specific confrence, 1487 set `conference_abv` to the abbreviation -1488 of the conference you want game information from. +1488 of the conference you want stats from. 1489 1490 `stat_category` (str, optional): 1491 Optional argument. @@ -6208,1553 +6220,1565 @@

Returns

1694 row_df = pd.DataFrame() 1695 url = "https://api.collegefootballdata.com/games/players" 1696 stat_columns = [ -1697 'game_id', -1698 'team_name', -1699 'team_confrence', -1700 'player_id', -1701 'player_name', -1702 'home_away', -1703 # PASS -1704 'passing_C/ATT', -1705 'passing_COMP', -1706 'passing_ATT', -1707 'passing_YDS', -1708 'passing_AVG', -1709 'passing_TD', -1710 'passing_INT', -1711 'passing_QBR', -1712 # RUSH -1713 'rushing_CAR', -1714 'rushing_YDS', -1715 'rushing_AVG', -1716 'rushing_TD', -1717 'rushing_LONG', -1718 # REC -1719 'receiving_REC', -1720 'receiving_YDS', -1721 'receiving_AVG', -1722 'receiving_TD', -1723 'receiving_LONG', -1724 # FUM -1725 'fumbles_FUM', -1726 'fumbles_LOST', -1727 'fumbles_REC', -1728 # DEFENSE -1729 'defensive_TOT', -1730 'defensive_SOLO', -1731 'defensive_TFL', -1732 'defensive_QB HUR', -1733 'defensive_SACKS', -1734 'defensive_PD', -1735 'defensive_TD', -1736 # INT -1737 'interceptions_INT', -1738 'interceptions_YDS', -1739 'interceptions_TD', -1740 # PUNT -1741 'punting_NO', -1742 'punting_YDS', -1743 'punting_AVG', -1744 'punting_TB', -1745 'punting_In 20', -1746 'punting_LONG', -1747 # KICK -1748 'kicking_FG', -1749 'kicking_FGM', -1750 'kicking_FGA', -1751 'kicking_PCT', -1752 'kicking_LONG', -1753 'kicking_XP', -1754 'kicking_XPM', -1755 'kicking_XPA', -1756 'kicking_PTS', -1757 # KR -1758 'kickReturns_NO', -1759 'kickReturns_YDS', -1760 'kickReturns_AVG', -1761 'kickReturns_TD', -1762 'kickReturns_LONG', -1763 # PR -1764 'puntReturns_NO', -1765 'puntReturns_YDS', -1766 'puntReturns_AVG', -1767 'puntReturns_TD', -1768 'puntReturns_LONG' -1769 ] -1770 -1771 ######################################################################################################################################################################################################## -1772 -1773 if api_key != None: -1774 real_api_key = api_key -1775 del api_key -1776 else: -1777 real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) -1778 -1779 if real_api_key == "tigersAreAwsome": -1780 raise ValueError( -1781 "You actually need to change `cfbd_key` to your CFBD API key.") -1782 elif "Bearer " in real_api_key: -1783 pass -1784 elif "Bearer" in real_api_key: -1785 real_api_key = real_api_key.replace('Bearer', 'Bearer ') -1786 else: -1787 real_api_key = "Bearer " + real_api_key -1788 -1789 if season == None: -1790 # This should never happen without user tampering, but if it does, -1791 # we need to raise an error, because the CFBD API will refuse this call without a valid season. -1792 raise SystemError( -1793 "I don't know how, I don't know why, " + -1794 "but you managed to call this function while `season` was `None` (NULL)," + -1795 " and the function got to this point in the code." + -1796 "\nIf you have a GitHub account, " + -1797 "please raise an issue on this python package's GitHub page:\n" + -1798 "https://github.com/armstjc/cfbd-json-py/issues" -1799 ) -1800 elif season > now.year: -1801 raise ValueError(f"`season` cannot be greater than {season}.") -1802 elif season < 1869: -1803 raise ValueError(f"`season` cannot be less than 1869.") -1804 -1805 if season_type != "regular" and season_type != "postseason": -1806 raise ValueError( -1807 "`season_type` must be set to either \"regular\" or " + -1808 "\"postseason\" for this function to work." -1809 ) -1810 -1811 # `week`, `team`, and/or `conference` -1812 # must be not null for this function to work. -1813 -1814 if week == None and team == None and conference_abv == None and game_id == None: -1815 raise ValueError( -1816 "To use `get_cfbd_player_game_stats()`," + -1817 " `week`, `team`, and/or `conference_abv` need to be set to a non-null value." -1818 ) -1819 -1820 filter_by_stat_category = False -1821 -1822 if stat_category == None: -1823 pass -1824 elif stat_category == "passing": -1825 filter_by_stat_category = True -1826 elif stat_category == "rushing": -1827 filter_by_stat_category = True -1828 elif stat_category == "receiving": -1829 filter_by_stat_category = True -1830 elif stat_category == "fumbles": -1831 filter_by_stat_category = True -1832 elif stat_category == "passing": -1833 filter_by_stat_category = True -1834 elif stat_category == "defensive": -1835 filter_by_stat_category = True -1836 elif stat_category == "interceptions": -1837 filter_by_stat_category = True -1838 elif stat_category == "punting": -1839 filter_by_stat_category = True -1840 elif stat_category == "kicking": -1841 filter_by_stat_category = True -1842 elif stat_category == "kickReturns": -1843 filter_by_stat_category = True -1844 elif stat_category == "puntReturns": -1845 filter_by_stat_category = True -1846 else: -1847 raise ValueError( -1848 "Invalid input for `stat_category`." + -1849 "\nValid inputs are:" + -1850 """ -1851 - `passing` -1852 - `rushing` -1853 - `receiving` -1854 - `fumbles` -1855 - `defensive` -1856 - `interceptions` -1857 - `punting` -1858 - `kicking` -1859 - `kickReturns` -1860 - `puntReturns` -1861 """ -1862 ) -1863 -1864 # URL builder -1865 ######################################################################################################################################################################################################## -1866 -1867 # Required by the API -1868 url += f"?year={season}" -1869 -1870 if game_id != None: -1871 url += f"&gameId={game_id}" -1872 -1873 if stat_category != None: -1874 url += f"&category={stat_category}" -1875 -1876 if week != None or team != None or conference_abv != None: -1877 logging.warning( -1878 "When calling `cfbd_json_py.games.get_cfbd_player_game_stats()`, " + -1879 "and setting `game_id` to a non-null value, " + -1880 "only `season`, `stat_category`, and `game_id` are considered " + -1881 "when calling the CFBD API." -1882 ) -1883 else: -1884 if season_type != None: -1885 url += f"&seasonType={season_type}" -1886 -1887 if week != None: -1888 url += f"&week={week}" -1889 -1890 if team != None: -1891 url += f"&team={team}" -1892 -1893 if conference_abv != None: -1894 url += f"&conference={conference_abv}" -1895 -1896 headers = { -1897 'Authorization': f'{real_api_key}', -1898 'accept': 'application/json' -1899 } -1900 -1901 response = requests.get(url, headers=headers) -1902 -1903 -1904 if response.status_code == 200: -1905 pass -1906 elif response.status_code == 401: -1907 raise ConnectionRefusedError( -1908 f'Could not connect. The connection was refused.\nHTTP Status Code 401.' -1909 ) -1910 else: -1911 raise ConnectionError( -1912 f'Could not connect.\nHTTP Status code {response.status_code}' -1913 ) -1914 -1915 json_data = response.json() -1916 -1917 if return_as_dict == True: -1918 return json_data -1919 -1920 for game in tqdm(json_data): -1921 game_id = game['id'] -1922 -1923 for team in game['teams']: -1924 team_name = team['school'] -1925 team_confrence = team['conference'] -1926 home_away = team['homeAway'] -1927 -1928 for s_category in team['categories']: -1929 if s_category['name'] == "passing": -1930 for stat in s_category['types']: -1931 -1932 if stat['name'] == "C/ATT": # passing_C/ATT -1933 -1934 for i in stat['athletes']: -1935 player_id = int(i['id']) -1936 player_name = i['name'] -1937 player_stat = i['stat'] -1938 -1939 if rebuilt_json.get(player_id) == None: -1940 rebuilt_json[player_id] = {} -1941 -1942 rebuilt_json[player_id]['game_id'] = game_id -1943 rebuilt_json[player_id]['team_name'] = team_name -1944 rebuilt_json[player_id]['team_confrence'] = team_confrence -1945 rebuilt_json[player_id]['player_id'] = player_id -1946 rebuilt_json[player_id]['player_name'] = player_name -1947 rebuilt_json[player_id]['home_away'] = home_away -1948 rebuilt_json[player_id]['passing_C/ATT'] = player_stat -1949 -1950 elif stat['name'] == "YDS": # passing_YDS -1951 -1952 for i in stat['athletes']: -1953 player_id = int(i['id']) -1954 player_name = i['name'] -1955 player_stat = int(i['stat']) -1956 -1957 if rebuilt_json.get(player_id) == None: -1958 rebuilt_json[player_id] = {} -1959 -1960 rebuilt_json[player_id]['game_id'] = game_id -1961 rebuilt_json[player_id]['team_name'] = team_name -1962 rebuilt_json[player_id]['team_confrence'] = team_confrence -1963 rebuilt_json[player_id]['player_id'] = player_id -1964 rebuilt_json[player_id]['player_name'] = player_name -1965 rebuilt_json[player_id]['home_away'] = home_away -1966 rebuilt_json[player_id]['passing_YDS'] = player_stat -1967 -1968 elif stat['name'] == "AVG": # passing_AVG -1969 for i in stat['athletes']: -1970 player_id = int(i['id']) -1971 player_name = i['name'] -1972 player_stat = float(i['stat']) -1973 -1974 if rebuilt_json.get(player_id) == None: -1975 rebuilt_json[player_id] = {} -1976 -1977 rebuilt_json[player_id]['game_id'] = game_id -1978 rebuilt_json[player_id]['team_name'] = team_name -1979 rebuilt_json[player_id]['team_confrence'] = team_confrence -1980 rebuilt_json[player_id]['player_id'] = player_id -1981 rebuilt_json[player_id]['player_name'] = player_name -1982 rebuilt_json[player_id]['home_away'] = home_away -1983 rebuilt_json[player_id]['passing_AVG'] = player_stat -1984 -1985 elif stat['name'] == "TD": # passing_TD -1986 -1987 for i in stat['athletes']: -1988 player_id = int(i['id']) -1989 player_name = i['name'] -1990 player_stat = int(i['stat']) -1991 -1992 if rebuilt_json.get(player_id) == None: -1993 rebuilt_json[player_id] = {} -1994 -1995 rebuilt_json[player_id]['game_id'] = game_id -1996 rebuilt_json[player_id]['team_name'] = team_name -1997 rebuilt_json[player_id]['team_confrence'] = team_confrence -1998 rebuilt_json[player_id]['player_id'] = player_id -1999 rebuilt_json[player_id]['player_name'] = player_name -2000 rebuilt_json[player_id]['home_away'] = home_away -2001 rebuilt_json[player_id]['passing_TD'] = player_stat -2002 -2003 elif stat['name'] == "INT": # passing_INT -2004 -2005 for i in stat['athletes']: -2006 player_id = int(i['id']) -2007 player_name = i['name'] -2008 player_stat = int(i['stat']) -2009 -2010 if rebuilt_json.get(player_id) == None: -2011 rebuilt_json[player_id] = {} -2012 -2013 rebuilt_json[player_id]['game_id'] = game_id -2014 rebuilt_json[player_id]['team_name'] = team_name -2015 rebuilt_json[player_id]['team_confrence'] = team_confrence -2016 rebuilt_json[player_id]['player_id'] = player_id -2017 rebuilt_json[player_id]['player_name'] = player_name -2018 rebuilt_json[player_id]['home_away'] = home_away -2019 rebuilt_json[player_id]['passing_INT'] = player_stat -2020 -2021 elif stat['name'] == "QBR": # passing_QBR -2022 for i in stat['athletes']: -2023 player_id = int(i['id']) -2024 player_name = i['name'] -2025 try: -2026 player_stat = float(i['stat']) -2027 except: -2028 player_stat = None -2029 -2030 if rebuilt_json.get(player_id) == None: -2031 rebuilt_json[player_id] = {} -2032 -2033 rebuilt_json[player_id]['game_id'] = game_id -2034 rebuilt_json[player_id]['team_name'] = team_name -2035 rebuilt_json[player_id]['team_confrence'] = team_confrence -2036 rebuilt_json[player_id]['player_id'] = player_id -2037 rebuilt_json[player_id]['player_name'] = player_name -2038 rebuilt_json[player_id]['home_away'] = home_away -2039 rebuilt_json[player_id]['passing_QBR'] = player_stat -2040 -2041 else: -2042 raise IndexError( -2043 f"Unhandled stat: \t{stat['name']}") -2044 # passing_df = pd.DataFrame(s_category['types']) -2045 elif s_category['name'] == "rushing": -2046 for stat in s_category['types']: -2047 if stat['name'] == "CAR": # rushing_CAR -2048 for i in stat['athletes']: -2049 player_id = int(i['id']) -2050 player_name = i['name'] -2051 player_stat = int(i['stat']) -2052 -2053 if rebuilt_json.get(player_id) == None: -2054 rebuilt_json[player_id] = {} -2055 -2056 rebuilt_json[player_id]['game_id'] = game_id -2057 rebuilt_json[player_id]['team_name'] = team_name -2058 rebuilt_json[player_id]['team_confrence'] = team_confrence -2059 rebuilt_json[player_id]['player_id'] = player_id -2060 rebuilt_json[player_id]['player_name'] = player_name -2061 rebuilt_json[player_id]['home_away'] = home_away -2062 rebuilt_json[player_id]['rushing_CAR'] = player_stat -2063 -2064 elif stat['name'] == "YDS": # rushing_YDS -2065 for i in stat['athletes']: -2066 player_id = int(i['id']) -2067 player_name = i['name'] -2068 player_stat = int(i['stat']) -2069 -2070 if rebuilt_json.get(player_id) == None: -2071 rebuilt_json[player_id] = {} -2072 -2073 rebuilt_json[player_id]['game_id'] = game_id -2074 rebuilt_json[player_id]['team_name'] = team_name -2075 rebuilt_json[player_id]['team_confrence'] = team_confrence -2076 rebuilt_json[player_id]['player_id'] = player_id -2077 rebuilt_json[player_id]['player_name'] = player_name -2078 rebuilt_json[player_id]['home_away'] = home_away -2079 rebuilt_json[player_id]['rushing_YDS'] = player_stat -2080 -2081 elif stat['name'] == "AVG": # rushing_AVG -2082 for i in stat['athletes']: -2083 player_id = int(i['id']) -2084 player_name = i['name'] -2085 player_stat = float(i['stat']) -2086 -2087 if rebuilt_json.get(player_id) == None: -2088 rebuilt_json[player_id] = {} -2089 -2090 rebuilt_json[player_id]['game_id'] = game_id -2091 rebuilt_json[player_id]['team_name'] = team_name -2092 rebuilt_json[player_id]['team_confrence'] = team_confrence -2093 rebuilt_json[player_id]['player_id'] = player_id -2094 rebuilt_json[player_id]['player_name'] = player_name -2095 rebuilt_json[player_id]['home_away'] = home_away -2096 rebuilt_json[player_id]['rushing_AVG'] = player_stat -2097 -2098 elif stat['name'] == "TD": # rushing_TD -2099 for i in stat['athletes']: -2100 player_id = int(i['id']) -2101 player_name = i['name'] -2102 player_stat = int(i['stat']) -2103 -2104 if rebuilt_json.get(player_id) == None: -2105 rebuilt_json[player_id] = {} -2106 -2107 rebuilt_json[player_id]['game_id'] = game_id -2108 rebuilt_json[player_id]['team_name'] = team_name -2109 rebuilt_json[player_id]['team_confrence'] = team_confrence -2110 rebuilt_json[player_id]['player_id'] = player_id -2111 rebuilt_json[player_id]['player_name'] = player_name -2112 rebuilt_json[player_id]['home_away'] = home_away -2113 rebuilt_json[player_id]['rushing_TD'] = player_stat -2114 -2115 elif stat['name'] == "LONG": # rushing_LONG -2116 for i in stat['athletes']: -2117 player_id = int(i['id']) -2118 player_name = i['name'] -2119 player_stat = int(i['stat']) -2120 -2121 if rebuilt_json.get(player_id) == None: -2122 rebuilt_json[player_id] = {} -2123 -2124 rebuilt_json[player_id]['game_id'] = game_id -2125 rebuilt_json[player_id]['team_name'] = team_name -2126 rebuilt_json[player_id]['team_confrence'] = team_confrence -2127 rebuilt_json[player_id]['player_id'] = player_id -2128 rebuilt_json[player_id]['player_name'] = player_name -2129 rebuilt_json[player_id]['home_away'] = home_away -2130 rebuilt_json[player_id]['rushing_LONG'] = player_stat -2131 -2132 else: -2133 raise IndexError( -2134 f"Unhandled stat: \t{stat['name']}") -2135 -2136 elif s_category['name'] == "receiving": -2137 for stat in s_category['types']: -2138 if stat['name'] == "REC": # receiving_REC -2139 for i in stat['athletes']: -2140 player_id = int(i['id']) -2141 player_name = i['name'] -2142 player_stat = int(i['stat']) -2143 -2144 if rebuilt_json.get(player_id) == None: -2145 rebuilt_json[player_id] = {} -2146 -2147 rebuilt_json[player_id]['game_id'] = game_id -2148 rebuilt_json[player_id]['team_name'] = team_name -2149 rebuilt_json[player_id]['team_confrence'] = team_confrence -2150 rebuilt_json[player_id]['player_id'] = player_id -2151 rebuilt_json[player_id]['player_name'] = player_name -2152 rebuilt_json[player_id]['home_away'] = home_away -2153 rebuilt_json[player_id]['receiving_REC'] = player_stat -2154 -2155 elif stat['name'] == "YDS": # receiving_YDS -2156 for i in stat['athletes']: -2157 player_id = int(i['id']) -2158 player_name = i['name'] -2159 player_stat = int(i['stat']) -2160 -2161 if rebuilt_json.get(player_id) == None: -2162 rebuilt_json[player_id] = {} -2163 -2164 rebuilt_json[player_id]['game_id'] = game_id -2165 rebuilt_json[player_id]['team_name'] = team_name -2166 rebuilt_json[player_id]['team_confrence'] = team_confrence -2167 rebuilt_json[player_id]['player_id'] = player_id -2168 rebuilt_json[player_id]['player_name'] = player_name -2169 rebuilt_json[player_id]['home_away'] = home_away -2170 rebuilt_json[player_id]['receiving_YDS'] = player_stat -2171 -2172 elif stat['name'] == "AVG": # receiving_AVG -2173 for i in stat['athletes']: -2174 player_id = int(i['id']) -2175 player_name = i['name'] -2176 player_stat = float(i['stat']) -2177 -2178 if rebuilt_json.get(player_id) == None: -2179 rebuilt_json[player_id] = {} -2180 -2181 rebuilt_json[player_id]['game_id'] = game_id -2182 rebuilt_json[player_id]['team_name'] = team_name -2183 rebuilt_json[player_id]['team_confrence'] = team_confrence -2184 rebuilt_json[player_id]['player_id'] = player_id -2185 rebuilt_json[player_id]['player_name'] = player_name -2186 rebuilt_json[player_id]['home_away'] = home_away -2187 rebuilt_json[player_id]['receiving_AVG'] = player_stat -2188 -2189 elif stat['name'] == "TD": # receiving_TD -2190 for i in stat['athletes']: -2191 player_id = int(i['id']) -2192 player_name = i['name'] -2193 player_stat = int(i['stat']) -2194 -2195 if rebuilt_json.get(player_id) == None: -2196 rebuilt_json[player_id] = {} -2197 -2198 rebuilt_json[player_id]['game_id'] = game_id -2199 rebuilt_json[player_id]['team_name'] = team_name -2200 rebuilt_json[player_id]['team_confrence'] = team_confrence -2201 rebuilt_json[player_id]['player_id'] = player_id -2202 rebuilt_json[player_id]['player_name'] = player_name -2203 rebuilt_json[player_id]['home_away'] = home_away -2204 rebuilt_json[player_id]['receiving_TD'] = player_stat -2205 -2206 elif stat['name'] == "LONG": # receiving_LONG -2207 for i in stat['athletes']: -2208 player_id = int(i['id']) -2209 player_name = i['name'] -2210 player_stat = int(i['stat']) -2211 -2212 if rebuilt_json.get(player_id) == None: -2213 rebuilt_json[player_id] = {} -2214 -2215 rebuilt_json[player_id]['game_id'] = game_id -2216 rebuilt_json[player_id]['team_name'] = team_name -2217 rebuilt_json[player_id]['team_confrence'] = team_confrence -2218 rebuilt_json[player_id]['player_id'] = player_id -2219 rebuilt_json[player_id]['player_name'] = player_name -2220 rebuilt_json[player_id]['home_away'] = home_away -2221 rebuilt_json[player_id]['receiving_LONG'] = player_stat -2222 -2223 else: -2224 raise IndexError( -2225 f"Unhandled stat: \t{stat['name']}") -2226 -2227 elif s_category['name'] == "fumbles": -2228 for stat in s_category['types']: -2229 if stat['name'] == "FUM": # fumbles_FUM -2230 for i in stat['athletes']: -2231 player_id = int(i['id']) -2232 player_name = i['name'] -2233 player_stat = int(i['stat']) -2234 -2235 if rebuilt_json.get(player_id) == None: -2236 rebuilt_json[player_id] = {} -2237 -2238 rebuilt_json[player_id]['game_id'] = game_id -2239 rebuilt_json[player_id]['team_name'] = team_name -2240 rebuilt_json[player_id]['team_confrence'] = team_confrence -2241 rebuilt_json[player_id]['player_id'] = player_id -2242 rebuilt_json[player_id]['player_name'] = player_name -2243 rebuilt_json[player_id]['home_away'] = home_away -2244 rebuilt_json[player_id]['fumbles_FUM'] = player_stat -2245 -2246 elif stat['name'] == "LOST": # fumbles_LOST -2247 for i in stat['athletes']: -2248 player_id = int(i['id']) -2249 player_name = i['name'] -2250 player_stat = int(i['stat']) -2251 -2252 if rebuilt_json.get(player_id) == None: -2253 rebuilt_json[player_id] = {} -2254 -2255 rebuilt_json[player_id]['game_id'] = game_id -2256 rebuilt_json[player_id]['team_name'] = team_name -2257 rebuilt_json[player_id]['team_confrence'] = team_confrence -2258 rebuilt_json[player_id]['player_id'] = player_id -2259 rebuilt_json[player_id]['player_name'] = player_name -2260 rebuilt_json[player_id]['home_away'] = home_away -2261 rebuilt_json[player_id]['fumbles_LOST'] = player_stat -2262 -2263 elif stat['name'] == "REC": # fumbles_REC -2264 for i in stat['athletes']: -2265 player_id = int(i['id']) -2266 player_name = i['name'] -2267 player_stat = int(i['stat']) -2268 -2269 if rebuilt_json.get(player_id) == None: -2270 rebuilt_json[player_id] = {} -2271 -2272 rebuilt_json[player_id]['game_id'] = game_id -2273 rebuilt_json[player_id]['team_name'] = team_name -2274 rebuilt_json[player_id]['team_confrence'] = team_confrence -2275 rebuilt_json[player_id]['player_id'] = player_id -2276 rebuilt_json[player_id]['player_name'] = player_name -2277 rebuilt_json[player_id]['home_away'] = home_away -2278 rebuilt_json[player_id]['fumbles_REC'] = player_stat -2279 -2280 else: -2281 raise IndexError( -2282 f"Unhandled stat: \t{stat['name']}") -2283 -2284 elif s_category['name'] == "defensive": -2285 for stat in s_category['types']: -2286 if stat['name'] == "TOT": # defensive_TOT -2287 for i in stat['athletes']: -2288 player_id = int(i['id']) -2289 player_name = i['name'] -2290 player_stat = int(i['stat']) -2291 -2292 if rebuilt_json.get(player_id) == None: -2293 rebuilt_json[player_id] = {} -2294 -2295 rebuilt_json[player_id]['game_id'] = game_id -2296 rebuilt_json[player_id]['team_name'] = team_name -2297 rebuilt_json[player_id]['team_confrence'] = team_confrence -2298 rebuilt_json[player_id]['player_id'] = player_id -2299 rebuilt_json[player_id]['player_name'] = player_name -2300 rebuilt_json[player_id]['home_away'] = home_away -2301 rebuilt_json[player_id]['defensive_TOT'] = player_stat -2302 -2303 elif stat['name'] == "SOLO": # defensive_SOLO -2304 for i in stat['athletes']: -2305 player_id = int(i['id']) -2306 player_name = i['name'] -2307 player_stat = int(i['stat']) -2308 -2309 if rebuilt_json.get(player_id) == None: -2310 rebuilt_json[player_id] = {} -2311 -2312 rebuilt_json[player_id]['game_id'] = game_id -2313 rebuilt_json[player_id]['team_name'] = team_name -2314 rebuilt_json[player_id]['team_confrence'] = team_confrence -2315 rebuilt_json[player_id]['player_id'] = player_id -2316 rebuilt_json[player_id]['player_name'] = player_name -2317 rebuilt_json[player_id]['home_away'] = home_away -2318 rebuilt_json[player_id]['defensive_SOLO'] = player_stat -2319 -2320 elif stat['name'] == "TFL": # defensive_TFL -2321 for i in stat['athletes']: -2322 player_id = int(i['id']) -2323 player_name = i['name'] -2324 player_stat = float(i['stat']) -2325 -2326 if rebuilt_json.get(player_id) == None: -2327 rebuilt_json[player_id] = {} -2328 -2329 rebuilt_json[player_id]['game_id'] = game_id -2330 rebuilt_json[player_id]['team_name'] = team_name -2331 rebuilt_json[player_id]['team_confrence'] = team_confrence -2332 rebuilt_json[player_id]['player_id'] = player_id -2333 rebuilt_json[player_id]['player_name'] = player_name -2334 rebuilt_json[player_id]['home_away'] = home_away -2335 rebuilt_json[player_id]['defensive_TFL'] = player_stat -2336 -2337 elif stat['name'] == "QB HUR": # defensive_QB HUR -2338 for i in stat['athletes']: -2339 player_id = int(i['id']) -2340 player_name = i['name'] -2341 player_stat = int(i['stat']) -2342 -2343 if rebuilt_json.get(player_id) == None: -2344 rebuilt_json[player_id] = {} -2345 -2346 rebuilt_json[player_id]['game_id'] = game_id -2347 rebuilt_json[player_id]['team_name'] = team_name -2348 rebuilt_json[player_id]['team_confrence'] = team_confrence -2349 rebuilt_json[player_id]['player_id'] = player_id -2350 rebuilt_json[player_id]['player_name'] = player_name -2351 rebuilt_json[player_id]['home_away'] = home_away -2352 rebuilt_json[player_id]['defensive_QB HUR'] = player_stat -2353 -2354 elif stat['name'] == "SACKS": # defensive_SACKS -2355 for i in stat['athletes']: -2356 player_id = int(i['id']) -2357 player_name = i['name'] -2358 player_stat = float(i['stat']) -2359 -2360 if rebuilt_json.get(player_id) == None: -2361 rebuilt_json[player_id] = {} -2362 -2363 rebuilt_json[player_id]['game_id'] = game_id -2364 rebuilt_json[player_id]['team_name'] = team_name -2365 rebuilt_json[player_id]['team_confrence'] = team_confrence -2366 rebuilt_json[player_id]['player_id'] = player_id -2367 rebuilt_json[player_id]['player_name'] = player_name -2368 rebuilt_json[player_id]['home_away'] = home_away -2369 rebuilt_json[player_id]['defensive_SACKS'] = player_stat -2370 -2371 elif stat['name'] == "PD": # defensive_PD -2372 for i in stat['athletes']: -2373 player_id = int(i['id']) -2374 player_name = i['name'] -2375 player_stat = int(i['stat']) -2376 -2377 if rebuilt_json.get(player_id) == None: -2378 rebuilt_json[player_id] = {} -2379 -2380 rebuilt_json[player_id]['game_id'] = game_id -2381 rebuilt_json[player_id]['team_name'] = team_name -2382 rebuilt_json[player_id]['team_confrence'] = team_confrence -2383 rebuilt_json[player_id]['player_id'] = player_id -2384 rebuilt_json[player_id]['player_name'] = player_name -2385 rebuilt_json[player_id]['home_away'] = home_away -2386 rebuilt_json[player_id]['defensive_PD'] = player_stat -2387 -2388 elif stat['name'] == "TD": # defensive_TD -2389 for i in stat['athletes']: -2390 player_id = int(i['id']) -2391 player_name = i['name'] -2392 player_stat = int(i['stat']) -2393 -2394 if rebuilt_json.get(player_id) == None: -2395 rebuilt_json[player_id] = {} -2396 -2397 rebuilt_json[player_id]['game_id'] = game_id -2398 rebuilt_json[player_id]['team_name'] = team_name -2399 rebuilt_json[player_id]['team_confrence'] = team_confrence -2400 rebuilt_json[player_id]['player_id'] = player_id -2401 rebuilt_json[player_id]['player_name'] = player_name -2402 rebuilt_json[player_id]['home_away'] = home_away -2403 rebuilt_json[player_id]['defensive_TD'] = player_stat -2404 -2405 else: -2406 raise IndexError( -2407 f"Unhandled stat: \t{stat['name']}") -2408 -2409 elif s_category['name'] == "interceptions": -2410 for stat in s_category['types']: -2411 if stat['name'] == "INT": # interceptions_INT -2412 for i in stat['athletes']: -2413 player_id = int(i['id']) -2414 player_name = i['name'] -2415 player_stat = int(i['stat']) -2416 -2417 if rebuilt_json.get(player_id) == None: -2418 rebuilt_json[player_id] = {} -2419 -2420 rebuilt_json[player_id]['game_id'] = game_id -2421 rebuilt_json[player_id]['team_name'] = team_name -2422 rebuilt_json[player_id]['team_confrence'] = team_confrence -2423 rebuilt_json[player_id]['player_id'] = player_id -2424 rebuilt_json[player_id]['player_name'] = player_name -2425 rebuilt_json[player_id]['home_away'] = home_away -2426 rebuilt_json[player_id]['interceptions_INT'] = player_stat -2427 -2428 elif stat['name'] == "YDS": # interceptions_YDS -2429 for i in stat['athletes']: -2430 player_id = int(i['id']) -2431 player_name = i['name'] -2432 player_stat = int(i['stat']) -2433 -2434 if rebuilt_json.get(player_id) == None: -2435 rebuilt_json[player_id] = {} -2436 -2437 rebuilt_json[player_id]['game_id'] = game_id -2438 rebuilt_json[player_id]['team_name'] = team_name -2439 rebuilt_json[player_id]['team_confrence'] = team_confrence -2440 rebuilt_json[player_id]['player_id'] = player_id -2441 rebuilt_json[player_id]['player_name'] = player_name -2442 rebuilt_json[player_id]['home_away'] = home_away -2443 rebuilt_json[player_id]['interceptions_YDS'] = player_stat -2444 -2445 elif stat['name'] == "TD": # interceptions_TD -2446 for i in stat['athletes']: -2447 player_id = int(i['id']) -2448 player_name = i['name'] -2449 player_stat = int(i['stat']) -2450 -2451 if rebuilt_json.get(player_id) == None: -2452 rebuilt_json[player_id] = {} -2453 -2454 rebuilt_json[player_id]['game_id'] = game_id -2455 rebuilt_json[player_id]['team_name'] = team_name -2456 rebuilt_json[player_id]['team_confrence'] = team_confrence -2457 rebuilt_json[player_id]['player_id'] = player_id -2458 rebuilt_json[player_id]['player_name'] = player_name -2459 rebuilt_json[player_id]['home_away'] = home_away -2460 rebuilt_json[player_id]['interceptions_TD'] = player_stat -2461 -2462 else: -2463 raise IndexError( -2464 f"Unhandled stat: \t{stat['name']}") -2465 -2466 elif s_category['name'] == "punting": -2467 for stat in s_category['types']: -2468 if stat['name'] == "NO": # punting_NO -2469 for i in stat['athletes']: -2470 player_id = int(i['id']) -2471 player_name = i['name'] -2472 player_stat = int(i['stat']) -2473 -2474 if rebuilt_json.get(player_id) == None: -2475 rebuilt_json[player_id] = {} -2476 -2477 rebuilt_json[player_id]['game_id'] = game_id -2478 rebuilt_json[player_id]['team_name'] = team_name -2479 rebuilt_json[player_id]['team_confrence'] = team_confrence -2480 rebuilt_json[player_id]['player_id'] = player_id -2481 rebuilt_json[player_id]['player_name'] = player_name -2482 rebuilt_json[player_id]['home_away'] = home_away -2483 rebuilt_json[player_id]['punting_NO'] = player_stat -2484 -2485 elif stat['name'] == "YDS": # punting_YDS -2486 for i in stat['athletes']: -2487 player_id = int(i['id']) -2488 player_name = i['name'] -2489 player_stat = int(i['stat']) -2490 -2491 if rebuilt_json.get(player_id) == None: -2492 rebuilt_json[player_id] = {} -2493 -2494 rebuilt_json[player_id]['game_id'] = game_id -2495 rebuilt_json[player_id]['team_name'] = team_name -2496 rebuilt_json[player_id]['team_confrence'] = team_confrence -2497 rebuilt_json[player_id]['player_id'] = player_id -2498 rebuilt_json[player_id]['player_name'] = player_name -2499 rebuilt_json[player_id]['home_away'] = home_away -2500 rebuilt_json[player_id]['punting_YDS'] = player_stat -2501 -2502 elif stat['name'] == "AVG": # punting_AVG -2503 for i in stat['athletes']: -2504 player_id = int(i['id']) -2505 player_name = i['name'] -2506 player_stat = float(i['stat']) -2507 -2508 if rebuilt_json.get(player_id) == None: -2509 rebuilt_json[player_id] = {} -2510 -2511 rebuilt_json[player_id]['game_id'] = game_id -2512 rebuilt_json[player_id]['team_name'] = team_name -2513 rebuilt_json[player_id]['team_confrence'] = team_confrence -2514 rebuilt_json[player_id]['player_id'] = player_id -2515 rebuilt_json[player_id]['player_name'] = player_name -2516 rebuilt_json[player_id]['home_away'] = home_away -2517 rebuilt_json[player_id]['punting_AVG'] = player_stat -2518 -2519 elif stat['name'] == "TB": # punting_TB -2520 for i in stat['athletes']: -2521 player_id = int(i['id']) -2522 player_name = i['name'] -2523 player_stat = int(i['stat']) -2524 -2525 if rebuilt_json.get(player_id) == None: -2526 rebuilt_json[player_id] = {} -2527 -2528 rebuilt_json[player_id]['game_id'] = game_id -2529 rebuilt_json[player_id]['team_name'] = team_name -2530 rebuilt_json[player_id]['team_confrence'] = team_confrence -2531 rebuilt_json[player_id]['player_id'] = player_id -2532 rebuilt_json[player_id]['player_name'] = player_name -2533 rebuilt_json[player_id]['home_away'] = home_away -2534 rebuilt_json[player_id]['punting_TB'] = player_stat -2535 -2536 elif stat['name'] == "In 20": # punting_In 20 -2537 for i in stat['athletes']: -2538 player_id = int(i['id']) -2539 player_name = i['name'] -2540 player_stat = int(i['stat']) -2541 -2542 if rebuilt_json.get(player_id) == None: -2543 rebuilt_json[player_id] = {} -2544 -2545 rebuilt_json[player_id]['game_id'] = game_id -2546 rebuilt_json[player_id]['team_name'] = team_name -2547 rebuilt_json[player_id]['team_confrence'] = team_confrence -2548 rebuilt_json[player_id]['player_id'] = player_id -2549 rebuilt_json[player_id]['player_name'] = player_name -2550 rebuilt_json[player_id]['home_away'] = home_away -2551 rebuilt_json[player_id]['punting_In 20'] = player_stat -2552 -2553 elif stat['name'] == "LONG": # punting_LONG -2554 for i in stat['athletes']: -2555 player_id = int(i['id']) -2556 player_name = i['name'] -2557 player_stat = int(i['stat']) -2558 -2559 if rebuilt_json.get(player_id) == None: -2560 rebuilt_json[player_id] = {} -2561 -2562 rebuilt_json[player_id]['game_id'] = game_id -2563 rebuilt_json[player_id]['team_name'] = team_name -2564 rebuilt_json[player_id]['team_confrence'] = team_confrence -2565 rebuilt_json[player_id]['player_id'] = player_id -2566 rebuilt_json[player_id]['player_name'] = player_name -2567 rebuilt_json[player_id]['home_away'] = home_away -2568 rebuilt_json[player_id]['punting_LONG'] = player_stat -2569 -2570 else: -2571 raise IndexError( -2572 f"Unhandled stat: \t{stat['name']}") -2573 -2574 elif s_category['name'] == "kicking": -2575 for stat in s_category['types']: -2576 if stat['name'] == "FG": # kicking_FG -2577 for i in stat['athletes']: -2578 player_id = int(i['id']) -2579 player_name = i['name'] -2580 player_stat = i['stat'] -2581 -2582 if rebuilt_json.get(player_id) == None: -2583 rebuilt_json[player_id] = {} -2584 -2585 rebuilt_json[player_id]['game_id'] = game_id -2586 rebuilt_json[player_id]['team_name'] = team_name -2587 rebuilt_json[player_id]['team_confrence'] = team_confrence -2588 rebuilt_json[player_id]['player_id'] = player_id -2589 rebuilt_json[player_id]['player_name'] = player_name -2590 rebuilt_json[player_id]['home_away'] = home_away -2591 rebuilt_json[player_id]['kicking_FG'] = player_stat -2592 -2593 elif stat['name'] == "TOT": # kicking_FG, special case -2594 for i in stat['athletes']: -2595 player_id = int(i['id']) -2596 player_name = i['name'] -2597 player_stat = i['stat'] -2598 -2599 if rebuilt_json.get(player_id) == None: -2600 rebuilt_json[player_id] = {} -2601 -2602 rebuilt_json[player_id]['game_id'] = game_id -2603 rebuilt_json[player_id]['team_name'] = team_name -2604 rebuilt_json[player_id]['team_confrence'] = team_confrence -2605 rebuilt_json[player_id]['player_id'] = player_id -2606 rebuilt_json[player_id]['player_name'] = player_name -2607 rebuilt_json[player_id]['home_away'] = home_away -2608 rebuilt_json[player_id]['kicking_FG'] = player_stat -2609 -2610 elif stat['name'] == "PCT": # kicking_PCT -2611 for i in stat['athletes']: -2612 player_id = int(i['id']) -2613 player_name = i['name'] -2614 player_stat = float(i['stat']) -2615 -2616 if rebuilt_json.get(player_id) == None: -2617 rebuilt_json[player_id] = {} -2618 -2619 rebuilt_json[player_id]['game_id'] = game_id -2620 rebuilt_json[player_id]['team_name'] = team_name -2621 rebuilt_json[player_id]['team_confrence'] = team_confrence -2622 rebuilt_json[player_id]['player_id'] = player_id -2623 rebuilt_json[player_id]['player_name'] = player_name -2624 rebuilt_json[player_id]['home_away'] = home_away -2625 rebuilt_json[player_id]['kicking_PCT'] = player_stat -2626 -2627 elif stat['name'] == "LONG": # kicking_LONG -2628 for i in stat['athletes']: -2629 player_id = int(i['id']) -2630 player_name = i['name'] -2631 player_stat = int(i['stat']) -2632 -2633 if rebuilt_json.get(player_id) == None: -2634 rebuilt_json[player_id] = {} -2635 -2636 rebuilt_json[player_id]['game_id'] = game_id -2637 rebuilt_json[player_id]['team_name'] = team_name -2638 rebuilt_json[player_id]['team_confrence'] = team_confrence -2639 rebuilt_json[player_id]['player_id'] = player_id -2640 rebuilt_json[player_id]['player_name'] = player_name -2641 rebuilt_json[player_id]['home_away'] = home_away -2642 rebuilt_json[player_id]['kicking_LONG'] = player_stat -2643 -2644 elif stat['name'] == "XP": # kicking_XP -2645 for i in stat['athletes']: -2646 player_id = int(i['id']) -2647 player_name = i['name'] -2648 player_stat = i['stat'] -2649 -2650 if rebuilt_json.get(player_id) == None: -2651 rebuilt_json[player_id] = {} -2652 -2653 rebuilt_json[player_id]['game_id'] = game_id -2654 rebuilt_json[player_id]['team_name'] = team_name -2655 rebuilt_json[player_id]['team_confrence'] = team_confrence -2656 rebuilt_json[player_id]['player_id'] = player_id -2657 rebuilt_json[player_id]['player_name'] = player_name -2658 rebuilt_json[player_id]['home_away'] = home_away -2659 rebuilt_json[player_id]['kicking_XP'] = player_stat -2660 -2661 elif stat['name'] == "PTS": # kicking_PTS -2662 for i in stat['athletes']: -2663 player_id = int(i['id']) -2664 player_name = i['name'] -2665 player_stat = int(i['stat']) -2666 -2667 if rebuilt_json.get(player_id) == None: -2668 rebuilt_json[player_id] = {} -2669 -2670 rebuilt_json[player_id]['game_id'] = game_id -2671 rebuilt_json[player_id]['team_name'] = team_name -2672 rebuilt_json[player_id]['team_confrence'] = team_confrence -2673 rebuilt_json[player_id]['player_id'] = player_id -2674 rebuilt_json[player_id]['player_name'] = player_name -2675 rebuilt_json[player_id]['home_away'] = home_away -2676 rebuilt_json[player_id]['kicking_PTS'] = player_stat -2677 -2678 else: -2679 raise IndexError( -2680 f"Unhandled stat: \t{stat['name']}") -2681 -2682 elif s_category['name'] == "kickReturns": -2683 for stat in s_category['types']: -2684 if stat['name'] == "NO": # kickReturns_NO -2685 for i in stat['athletes']: -2686 player_id = int(i['id']) -2687 player_name = i['name'] -2688 player_stat = int(i['stat']) -2689 -2690 if rebuilt_json.get(player_id) == None: -2691 rebuilt_json[player_id] = {} -2692 -2693 rebuilt_json[player_id]['game_id'] = game_id -2694 rebuilt_json[player_id]['team_name'] = team_name -2695 rebuilt_json[player_id]['team_confrence'] = team_confrence -2696 rebuilt_json[player_id]['player_id'] = player_id -2697 rebuilt_json[player_id]['player_name'] = player_name -2698 rebuilt_json[player_id]['home_away'] = home_away -2699 rebuilt_json[player_id]['kickReturns_NO'] = player_stat -2700 -2701 elif stat['name'] == "YDS": # kickReturns_YDS -2702 for i in stat['athletes']: -2703 player_id = int(i['id']) -2704 player_name = i['name'] -2705 player_stat = int(i['stat']) -2706 -2707 if rebuilt_json.get(player_id) == None: -2708 rebuilt_json[player_id] = {} -2709 -2710 rebuilt_json[player_id]['game_id'] = game_id -2711 rebuilt_json[player_id]['team_name'] = team_name -2712 rebuilt_json[player_id]['team_confrence'] = team_confrence -2713 rebuilt_json[player_id]['player_id'] = player_id -2714 rebuilt_json[player_id]['player_name'] = player_name -2715 rebuilt_json[player_id]['home_away'] = home_away -2716 rebuilt_json[player_id]['kickReturns_YDS'] = player_stat -2717 -2718 elif stat['name'] == "AVG": # kickReturns_AVG -2719 for i in stat['athletes']: -2720 player_id = int(i['id']) -2721 player_name = i['name'] -2722 player_stat = float(i['stat']) -2723 -2724 if rebuilt_json.get(player_id) == None: -2725 rebuilt_json[player_id] = {} -2726 -2727 rebuilt_json[player_id]['game_id'] = game_id -2728 rebuilt_json[player_id]['team_name'] = team_name -2729 rebuilt_json[player_id]['team_confrence'] = team_confrence -2730 rebuilt_json[player_id]['player_id'] = player_id -2731 rebuilt_json[player_id]['player_name'] = player_name -2732 rebuilt_json[player_id]['home_away'] = home_away -2733 rebuilt_json[player_id]['kickReturns_AVG'] = player_stat -2734 -2735 elif stat['name'] == "TD": # kickReturns_TD -2736 for i in stat['athletes']: -2737 player_id = int(i['id']) -2738 player_name = i['name'] -2739 player_stat = int(i['stat']) -2740 -2741 if rebuilt_json.get(player_id) == None: -2742 rebuilt_json[player_id] = {} -2743 -2744 rebuilt_json[player_id]['game_id'] = game_id -2745 rebuilt_json[player_id]['team_name'] = team_name -2746 rebuilt_json[player_id]['team_confrence'] = team_confrence -2747 rebuilt_json[player_id]['player_id'] = player_id -2748 rebuilt_json[player_id]['player_name'] = player_name -2749 rebuilt_json[player_id]['home_away'] = home_away -2750 rebuilt_json[player_id]['kickReturns_TD'] = player_stat -2751 -2752 elif stat['name'] == "LONG": # kickReturns_LONG -2753 for i in stat['athletes']: -2754 player_id = int(i['id']) -2755 player_name = i['name'] -2756 player_stat = int(i['stat']) -2757 -2758 if rebuilt_json.get(player_id) == None: -2759 rebuilt_json[player_id] = {} -2760 -2761 rebuilt_json[player_id]['game_id'] = game_id -2762 rebuilt_json[player_id]['team_name'] = team_name -2763 rebuilt_json[player_id]['team_confrence'] = team_confrence -2764 rebuilt_json[player_id]['player_id'] = player_id -2765 rebuilt_json[player_id]['player_name'] = player_name -2766 rebuilt_json[player_id]['home_away'] = home_away -2767 rebuilt_json[player_id]['kickReturns_LONG'] = player_stat -2768 -2769 else: -2770 raise IndexError( -2771 f"Unhandled stat: \t{stat['name']}") -2772 -2773 elif s_category['name'] == "puntReturns": -2774 for stat in s_category['types']: -2775 if stat['name'] == "NO": # puntReturns_NO -2776 for i in stat['athletes']: -2777 player_id = int(i['id']) -2778 player_name = i['name'] -2779 player_stat = int(i['stat']) -2780 -2781 if rebuilt_json.get(player_id) == None: -2782 rebuilt_json[player_id] = {} -2783 -2784 rebuilt_json[player_id]['game_id'] = game_id -2785 rebuilt_json[player_id]['team_name'] = team_name -2786 rebuilt_json[player_id]['team_confrence'] = team_confrence -2787 rebuilt_json[player_id]['player_id'] = player_id -2788 rebuilt_json[player_id]['player_name'] = player_name -2789 rebuilt_json[player_id]['home_away'] = home_away -2790 rebuilt_json[player_id]['puntReturns_NO'] = player_stat -2791 -2792 elif stat['name'] == "YDS": # puntReturns_YDS -2793 for i in stat['athletes']: -2794 player_id = int(i['id']) -2795 player_name = i['name'] -2796 player_stat = int(i['stat']) -2797 -2798 if rebuilt_json.get(player_id) == None: -2799 rebuilt_json[player_id] = {} -2800 -2801 rebuilt_json[player_id]['game_id'] = game_id -2802 rebuilt_json[player_id]['team_name'] = team_name -2803 rebuilt_json[player_id]['team_confrence'] = team_confrence -2804 rebuilt_json[player_id]['player_id'] = player_id -2805 rebuilt_json[player_id]['player_name'] = player_name -2806 rebuilt_json[player_id]['home_away'] = home_away -2807 rebuilt_json[player_id]['puntReturns_YDS'] = player_stat -2808 -2809 elif stat['name'] == "AVG": # puntReturns_AVG -2810 for i in stat['athletes']: -2811 player_id = int(i['id']) -2812 player_name = i['name'] -2813 player_stat = float(i['stat']) -2814 -2815 if rebuilt_json.get(player_id) == None: -2816 rebuilt_json[player_id] = {} -2817 -2818 rebuilt_json[player_id]['game_id'] = game_id -2819 rebuilt_json[player_id]['team_name'] = team_name -2820 rebuilt_json[player_id]['team_confrence'] = team_confrence -2821 rebuilt_json[player_id]['player_id'] = player_id -2822 rebuilt_json[player_id]['player_name'] = player_name -2823 rebuilt_json[player_id]['home_away'] = home_away -2824 rebuilt_json[player_id]['puntReturns_AVG'] = player_stat -2825 -2826 elif stat['name'] == "TD": # puntReturns_TD -2827 for i in stat['athletes']: -2828 player_id = int(i['id']) -2829 player_name = i['name'] -2830 player_stat = int(i['stat']) -2831 -2832 if rebuilt_json.get(player_id) == None: -2833 rebuilt_json[player_id] = {} -2834 -2835 rebuilt_json[player_id]['game_id'] = game_id -2836 rebuilt_json[player_id]['team_name'] = team_name -2837 rebuilt_json[player_id]['team_confrence'] = team_confrence -2838 rebuilt_json[player_id]['player_id'] = player_id -2839 rebuilt_json[player_id]['player_name'] = player_name -2840 rebuilt_json[player_id]['home_away'] = home_away -2841 rebuilt_json[player_id]['puntReturns_TD'] = player_stat -2842 -2843 elif stat['name'] == "LONG": # puntReturns_LONG -2844 for i in stat['athletes']: -2845 player_id = int(i['id']) -2846 player_name = i['name'] -2847 player_stat = int(i['stat']) -2848 -2849 if rebuilt_json.get(player_id) == None: -2850 rebuilt_json[player_id] = {} -2851 -2852 rebuilt_json[player_id]['game_id'] = game_id -2853 rebuilt_json[player_id]['team_name'] = team_name -2854 rebuilt_json[player_id]['team_confrence'] = team_confrence -2855 rebuilt_json[player_id]['player_id'] = player_id -2856 rebuilt_json[player_id]['player_name'] = player_name -2857 rebuilt_json[player_id]['home_away'] = home_away -2858 rebuilt_json[player_id]['puntReturns_LONG'] = player_stat -2859 -2860 else: -2861 raise IndexError( -2862 f"Unhandled stat: \t{stat['name']}") -2863 -2864 else: -2865 raise IndexError( -2866 f"Unhandled stat category: \t{s_category['name']}" -2867 ) -2868 -2869 for key, value in tqdm(rebuilt_json.items()): -2870 # print(key) -2871 -2872 # print(value) -2873 game_id = value['game_id'] -2874 team_name = value['team_name'] -2875 team_confrence = value['team_confrence'] -2876 player_id = value['player_id'] -2877 player_name = value['player_name'] -2878 home_away = value['home_away'] -2879 -2880 row_df = pd.DataFrame( -2881 { -2882 "game_id": game_id, -2883 "team_name": team_name, -2884 "team_confrence": team_confrence, -2885 "player_id": player_id, -2886 "player_name": player_name, -2887 "home_away": home_away -2888 }, -2889 index=[0] -2890 ) -2891 # Passing -2892 if value.get('passing_C/ATT') != None: -2893 row_df['passing_C/ATT'] = value['passing_C/ATT'] -2894 -2895 if value.get('passing_YDS') != None: -2896 row_df['passing_YDS'] = value['passing_YDS'] -2897 -2898 if value.get('passing_AVG') != None: -2899 row_df['passing_AVG'] = value['passing_AVG'] -2900 -2901 if value.get('passing_TD') != None: -2902 row_df['passing_TD'] = value['passing_TD'] -2903 -2904 if value.get('passing_INT') != None: -2905 row_df['passing_INT'] = value['passing_INT'] -2906 -2907 if value.get('passing_QBR') != None: -2908 row_df['passing_QBR'] = value['passing_QBR'] -2909 -2910 # Rushing -2911 if value.get('rushing_CAR') != None: -2912 row_df['rushing_CAR'] = value['rushing_CAR'] -2913 -2914 if value.get('rushing_YDS') != None: -2915 row_df['rushing_YDS'] = value['rushing_YDS'] -2916 -2917 if value.get('rushing_AVG') != None: -2918 row_df['rushing_AVG'] = value['rushing_AVG'] -2919 -2920 if value.get('rushing_TD') != None: -2921 row_df['rushing_TD'] = value['rushing_TD'] -2922 -2923 if value.get('rushing_LONG') != None: -2924 row_df['rushing_LONG'] = value['rushing_LONG'] -2925 -2926 # Receiving -2927 if value.get('receiving_REC') != None: -2928 row_df['receiving_REC'] = value['receiving_REC'] -2929 -2930 if value.get('receiving_YDS') != None: -2931 row_df['receiving_YDS'] = value['receiving_YDS'] -2932 -2933 if value.get('receiving_AVG') != None: -2934 row_df['receiving_AVG'] = value['receiving_AVG'] -2935 -2936 if value.get('receiving_TD') != None: -2937 row_df['receiving_TD'] = value['receiving_TD'] -2938 -2939 if value.get('receiving_LONG') != None: -2940 row_df['receiving_LONG'] = value['receiving_LONG'] -2941 -2942 # Fumbles -2943 if value.get('fumbles_FUM') != None: -2944 row_df['fumbles_FUM'] = value['fumbles_FUM'] -2945 -2946 if value.get('fumbles_LOST') != None: -2947 row_df['fumbles_LOST'] = value['fumbles_LOST'] -2948 -2949 if value.get('fumbles_REC') != None: -2950 row_df['fumbles_REC'] = value['fumbles_REC'] -2951 -2952 # Defense -2953 if value.get('defensive_TOT') != None: -2954 row_df['defensive_TOT'] = value['defensive_TOT'] -2955 -2956 if value.get('defensive_SOLO') != None: -2957 row_df['defensive_SOLO'] = value['defensive_SOLO'] -2958 -2959 if value.get('defensive_TFL') != None: -2960 row_df['defensive_TFL'] = value['defensive_TFL'] -2961 -2962 if value.get('defensive_QB HUR') != None: -2963 row_df['defensive_QB HUR'] = value['defensive_QB HUR'] -2964 -2965 if value.get('defensive_SACKS') != None: -2966 row_df['defensive_SACKS'] = value['defensive_SACKS'] -2967 -2968 if value.get('defensive_PD') != None: -2969 row_df['defensive_PD'] = value['defensive_PD'] -2970 -2971 if value.get('defensive_TD') != None: -2972 row_df['defensive_TD'] = value['defensive_TD'] -2973 -2974 # interceptions -2975 if value.get('interceptions_INT') != None: -2976 row_df['interceptions_INT'] = value['interceptions_INT'] -2977 -2978 if value.get('interceptions_YDS') != None: -2979 row_df['interceptions_YDS'] = value['interceptions_YDS'] -2980 -2981 if value.get('interceptions_TD') != None: -2982 row_df['interceptions_TD'] = value['interceptions_TD'] -2983 -2984 # punting -2985 if value.get('punting_NO') != None: -2986 row_df['punting_NO'] = value['punting_NO'] -2987 -2988 if value.get('punting_YDS') != None: -2989 row_df['punting_YDS'] = value['punting_YDS'] -2990 -2991 if value.get('punting_AVG') != None: -2992 row_df['punting_AVG'] = value['punting_AVG'] -2993 -2994 if value.get('punting_TB') != None: -2995 row_df['punting_TB'] = value['punting_TB'] -2996 -2997 if value.get('punting_In 20') != None: -2998 row_df['punting_In 20'] = value['punting_In 20'] -2999 -3000 if value.get('punting_LONG') != None: -3001 row_df['punting_LONG'] = value['punting_LONG'] -3002 -3003 # kicking -3004 if value.get('kicking_FG') != None: -3005 row_df['kicking_FG'] = value['kicking_FG'] -3006 -3007 if value.get('kicking_PCT') != None: -3008 row_df['kicking_PCT'] = value['kicking_PCT'] -3009 -3010 if value.get('kicking_LONG') != None: -3011 row_df['kicking_LONG'] = value['kicking_LONG'] -3012 -3013 if value.get('kicking_XP') != None: -3014 row_df['kicking_XP'] = value['kicking_XP'] -3015 -3016 if value.get('kicking_PTS') != None: -3017 row_df['kicking_PTS'] = value['kicking_PTS'] -3018 -3019 # kickReturns -3020 if value.get('kickReturns_NO') != None: -3021 row_df['kickReturns_NO'] = value['kickReturns_NO'] -3022 -3023 if value.get('kickReturns_YDS') != None: -3024 row_df['kickReturns_YDS'] = value['kickReturns_YDS'] -3025 -3026 if value.get('kickReturns_AVG') != None: -3027 row_df['kickReturns_AVG'] = value['kickReturns_AVG'] -3028 -3029 if value.get('kickReturns_TD') != None: -3030 row_df['kickReturns_TD'] = value['kickReturns_TD'] -3031 -3032 if value.get('kickReturns_LONG') != None: -3033 row_df['kickReturns_LONG'] = value['kickReturns_LONG'] -3034 -3035 # puntReturns -3036 if value.get('puntReturns_NO') != None: -3037 row_df['puntReturns_NO'] = value['puntReturns_NO'] -3038 -3039 if value.get('puntReturns_YDS') != None: -3040 row_df['puntReturns_YDS'] = value['puntReturns_YDS'] -3041 -3042 if value.get('puntReturns_AVG') != None: -3043 row_df['puntReturns_AVG'] = value['puntReturns_AVG'] -3044 -3045 if value.get('puntReturns_TD') != None: -3046 row_df['puntReturns_TD'] = value['puntReturns_TD'] -3047 -3048 if value.get('puntReturns_LONG') != None: -3049 row_df['puntReturns_LONG'] = value['puntReturns_LONG'] -3050 -3051 cfb_games_df = pd.concat([cfb_games_df, row_df], ignore_index=True) -3052 del row_df -3053 -3054 cfb_games_df[['passing_COMP', 'passing_ATT'] -3055 ] = cfb_games_df['passing_C/ATT'].str.split('/', expand=True) -3056 -3057 cfb_games_df[['kicking_FGM', 'kicking_FGA'] -3058 ] = cfb_games_df['kicking_FG'].str.split('/', expand=True) -3059 cfb_games_df[['kicking_XPM', 'kicking_XPA'] -3060 ] = cfb_games_df['kicking_XP'].str.split('/', expand=True) -3061 -3062 cfb_games_df = cfb_games_df.fillna(0) -3063 -3064 cfb_games_df = cfb_games_df.astype({ -3065 "passing_COMP": "int", -3066 "passing_ATT": "int", -3067 "kicking_FGM": "int", -3068 "kicking_FGA": "int", -3069 "kicking_XPM": "int", -3070 "kicking_XPA": "int" -3071 }) -3072 # print(cfb_games_df.columns) -3073 -3074 if filter_by_stat_category == False: -3075 cfb_games_df = cfb_games_df.reindex(columns=stat_columns) -3076 -3077 elif filter_by_stat_category == True and stat_category == "passing": -3078 cfb_games_df = cfb_games_df[[ -3079 'game_id', -3080 'team_name', -3081 'team_confrence', -3082 'player_id', -3083 'player_name', -3084 'home_away', -3085 # PASS -3086 'passing_C/ATT', -3087 'passing_COMP', -3088 'passing_ATT', -3089 'passing_YDS', -3090 'passing_AVG', -3091 'passing_TD', -3092 'passing_INT', -3093 'passing_QBR' -3094 ]] -3095 -3096 elif filter_by_stat_category == True and stat_category == "rushing": -3097 cfb_games_df = cfb_games_df[[ -3098 'game_id', -3099 'team_name', -3100 'team_confrence', -3101 'player_id', -3102 'player_name', -3103 'home_away', -3104 # RUSH -3105 'rushing_CAR', -3106 'rushing_YDS', -3107 'rushing_AVG', -3108 'rushing_TD', -3109 'rushing_LONG', -3110 ]] -3111 -3112 elif filter_by_stat_category == True and stat_category == "receiving": -3113 cfb_games_df = cfb_games_df[[ -3114 'game_id', -3115 'team_name', -3116 'team_confrence', -3117 'player_id', -3118 'player_name', -3119 'home_away', -3120 # REC -3121 'receiving_REC', -3122 'receiving_YDS', -3123 'receiving_AVG', -3124 'receiving_TD', -3125 'receiving_LONG' -3126 ]] -3127 -3128 elif filter_by_stat_category == True and stat_category == "fumbles": -3129 cfb_games_df = cfb_games_df[[ -3130 'game_id', -3131 'team_name', -3132 'team_confrence', -3133 'player_id', -3134 'player_name', -3135 'home_away', -3136 # FUM -3137 'fumbles_FUM', -3138 'fumbles_LOST', -3139 'fumbles_REC' -3140 ]] -3141 -3142 elif filter_by_stat_category == True and stat_category == "defensive": -3143 cfb_games_df = cfb_games_df[[ -3144 'game_id', -3145 'team_name', -3146 'team_confrence', -3147 'player_id', -3148 'player_name', -3149 'home_away', -3150 # DEFENSE -3151 'defensive_TOT', -3152 'defensive_SOLO', -3153 'defensive_TFL', -3154 'defensive_QB HUR', -3155 'defensive_SACKS', -3156 'defensive_PD', -3157 'defensive_TD' -3158 ]] -3159 -3160 elif filter_by_stat_category == True and stat_category == "interceptions": -3161 cfb_games_df = cfb_games_df[[ -3162 'game_id', -3163 'team_name', -3164 'team_confrence', -3165 'player_id', -3166 'player_name', -3167 'home_away', -3168 # INT -3169 'interceptions_INT', -3170 'interceptions_YDS', -3171 'interceptions_TD', -3172 ]] -3173 -3174 elif filter_by_stat_category == True and stat_category == "punting": -3175 cfb_games_df = cfb_games_df[[ -3176 'game_id', -3177 'team_name', -3178 'team_confrence', -3179 'player_id', -3180 'player_name', -3181 'home_away', -3182 # PUNT -3183 'punting_NO', -3184 'punting_YDS', -3185 'punting_AVG', -3186 'punting_TB', -3187 'punting_In 20', -3188 'punting_LONG' -3189 ]] -3190 -3191 elif filter_by_stat_category == True and stat_category == "kicking": -3192 cfb_games_df = cfb_games_df[[ -3193 'game_id', -3194 'team_name', -3195 'team_confrence', -3196 'player_id', -3197 'player_name', -3198 'home_away', -3199 # KICK -3200 'kicking_FG', -3201 'kicking_FGM', -3202 'kicking_FGA', -3203 'kicking_PCT', -3204 'kicking_LONG', -3205 'kicking_XP', -3206 'kicking_XPM', -3207 'kicking_XPA', -3208 'kicking_PTS' -3209 ]] -3210 -3211 elif filter_by_stat_category == True and stat_category == "kickReturns": -3212 cfb_games_df = cfb_games_df[[ -3213 'game_id', -3214 'team_name', -3215 'team_confrence', -3216 'player_id', -3217 'player_name', -3218 'home_away', -3219 # KR -3220 'kickReturns_NO', -3221 'kickReturns_YDS', -3222 'kickReturns_AVG', -3223 'kickReturns_TD', -3224 'kickReturns_LONG' -3225 ]] -3226 -3227 elif filter_by_stat_category == True and stat_category == "puntReturns": -3228 cfb_games_df = cfb_games_df[[ -3229 'game_id', -3230 'team_name', -3231 'team_confrence', -3232 'player_id', -3233 'player_name', -3234 'home_away', -3235 # KR -3236 'puntReturns_NO', -3237 'puntReturns_YDS', -3238 'puntReturns_AVG', -3239 'puntReturns_TD', -3240 'puntReturns_LONG' -3241 ]] -3242 -3243 return cfb_games_df +1697 'season', +1698 'game_id', +1699 'team_name', +1700 'team_confrence', +1701 'player_id', +1702 'player_name', +1703 'home_away', +1704 # PASS +1705 'passing_C/ATT', +1706 'passing_COMP', +1707 'passing_ATT', +1708 'passing_YDS', +1709 'passing_AVG', +1710 'passing_TD', +1711 'passing_INT', +1712 'passing_QBR', +1713 # RUSH +1714 'rushing_CAR', +1715 'rushing_YDS', +1716 'rushing_AVG', +1717 'rushing_TD', +1718 'rushing_LONG', +1719 # REC +1720 'receiving_REC', +1721 'receiving_YDS', +1722 'receiving_AVG', +1723 'receiving_TD', +1724 'receiving_LONG', +1725 # FUM +1726 'fumbles_FUM', +1727 'fumbles_LOST', +1728 'fumbles_REC', +1729 # DEFENSE +1730 'defensive_TOT', +1731 'defensive_SOLO', +1732 'defensive_TFL', +1733 'defensive_QB HUR', +1734 'defensive_SACKS', +1735 'defensive_PD', +1736 'defensive_TD', +1737 # INT +1738 'interceptions_INT', +1739 'interceptions_YDS', +1740 'interceptions_TD', +1741 # PUNT +1742 'punting_NO', +1743 'punting_YDS', +1744 'punting_AVG', +1745 'punting_TB', +1746 'punting_In 20', +1747 'punting_LONG', +1748 # KICK +1749 'kicking_FG', +1750 'kicking_FGM', +1751 'kicking_FGA', +1752 'kicking_PCT', +1753 'kicking_LONG', +1754 'kicking_XP', +1755 'kicking_XPM', +1756 'kicking_XPA', +1757 'kicking_PTS', +1758 # KR +1759 'kickReturns_NO', +1760 'kickReturns_YDS', +1761 'kickReturns_AVG', +1762 'kickReturns_TD', +1763 'kickReturns_LONG', +1764 # PR +1765 'puntReturns_NO', +1766 'puntReturns_YDS', +1767 'puntReturns_AVG', +1768 'puntReturns_TD', +1769 'puntReturns_LONG' +1770 ] +1771 +1772 ######################################################################################################################################################################################################## +1773 +1774 if api_key != None: +1775 real_api_key = api_key +1776 del api_key +1777 else: +1778 real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir) +1779 +1780 if real_api_key == "tigersAreAwsome": +1781 raise ValueError( +1782 "You actually need to change `cfbd_key` to your CFBD API key.") +1783 elif "Bearer " in real_api_key: +1784 pass +1785 elif "Bearer" in real_api_key: +1786 real_api_key = real_api_key.replace('Bearer', 'Bearer ') +1787 else: +1788 real_api_key = "Bearer " + real_api_key +1789 +1790 if season == None: +1791 # This should never happen without user tampering, but if it does, +1792 # we need to raise an error, because the CFBD API will refuse this call without a valid season. +1793 raise SystemError( +1794 "I don't know how, I don't know why, " + +1795 "but you managed to call this function while `season` was `None` (NULL)," + +1796 " and the function got to this point in the code." + +1797 "\nIf you have a GitHub account, " + +1798 "please raise an issue on this python package's GitHub page:\n" + +1799 "https://github.com/armstjc/cfbd-json-py/issues" +1800 ) +1801 elif season > (now.year + 1): +1802 raise ValueError(f"`season` cannot be greater than {season}.") +1803 elif season < 1869: +1804 raise ValueError(f"`season` cannot be less than 1869.") +1805 +1806 if season_type != "regular" and season_type != "postseason": +1807 raise ValueError( +1808 "`season_type` must be set to either \"regular\" or " + +1809 "\"postseason\" for this function to work." +1810 ) +1811 +1812 # `week`, `team`, and/or `conference` +1813 # must be not null for this function to work. +1814 +1815 if week == None and team == None and conference_abv == None and game_id == None: +1816 raise ValueError( +1817 "To use `get_cfbd_player_game_stats()`," + +1818 " `week`, `team`, and/or `conference_abv` need to be set to a non-null value." +1819 ) +1820 +1821 filter_by_stat_category = False +1822 +1823 if stat_category == None: +1824 pass +1825 elif stat_category == "passing": +1826 filter_by_stat_category = True +1827 elif stat_category == "rushing": +1828 filter_by_stat_category = True +1829 elif stat_category == "receiving": +1830 filter_by_stat_category = True +1831 elif stat_category == "fumbles": +1832 filter_by_stat_category = True +1833 elif stat_category == "passing": +1834 filter_by_stat_category = True +1835 elif stat_category == "defensive": +1836 filter_by_stat_category = True +1837 elif stat_category == "interceptions": +1838 filter_by_stat_category = True +1839 elif stat_category == "punting": +1840 filter_by_stat_category = True +1841 elif stat_category == "kicking": +1842 filter_by_stat_category = True +1843 elif stat_category == "kickReturns": +1844 filter_by_stat_category = True +1845 elif stat_category == "puntReturns": +1846 filter_by_stat_category = True +1847 else: +1848 raise ValueError( +1849 "Invalid input for `stat_category`." + +1850 "\nValid inputs are:" + +1851 """ +1852 - `passing` +1853 - `rushing` +1854 - `receiving` +1855 - `fumbles` +1856 - `defensive` +1857 - `interceptions` +1858 - `punting` +1859 - `kicking` +1860 - `kickReturns` +1861 - `puntReturns` +1862 """ +1863 ) +1864 +1865 # URL builder +1866 ######################################################################################################################################################################################################## +1867 +1868 # Required by the API +1869 url += f"?year={season}" +1870 +1871 if game_id != None: +1872 url += f"&gameId={game_id}" +1873 +1874 if stat_category != None: +1875 url += f"&category={stat_category}" +1876 +1877 if week != None or team != None or conference_abv != None: +1878 logging.warning( +1879 "When calling `cfbd_json_py.games.get_cfbd_player_game_stats()`, " + +1880 "and setting `game_id` to a non-null value, " + +1881 "only `season`, `stat_category`, and `game_id` are considered " + +1882 "when calling the CFBD API." +1883 ) +1884 else: +1885 if season_type != None: +1886 url += f"&seasonType={season_type}" +1887 +1888 if week != None: +1889 url += f"&week={week}" +1890 +1891 if team != None: +1892 url += f"&team={team}" +1893 +1894 if conference_abv != None: +1895 url += f"&conference={conference_abv}" +1896 +1897 headers = { +1898 'Authorization': f'{real_api_key}', +1899 'accept': 'application/json' +1900 } +1901 +1902 response = requests.get(url, headers=headers) +1903 +1904 +1905 if response.status_code == 200: +1906 pass +1907 elif response.status_code == 401: +1908 raise ConnectionRefusedError( +1909 f'Could not connect. The connection was refused.\nHTTP Status Code 401.' +1910 ) +1911 else: +1912 raise ConnectionError( +1913 f'Could not connect.\nHTTP Status code {response.status_code}' +1914 ) +1915 +1916 json_data = response.json() +1917 +1918 if return_as_dict == True: +1919 return json_data +1920 +1921 for game in tqdm(json_data): +1922 game_id = game['id'] +1923 +1924 for team in game['teams']: +1925 team_name = team['school'] +1926 team_confrence = team['conference'] +1927 home_away = team['homeAway'] +1928 +1929 for s_category in team['categories']: +1930 if s_category['name'] == "passing": +1931 for stat in s_category['types']: +1932 +1933 if stat['name'] == "C/ATT": # passing_C/ATT +1934 +1935 for i in stat['athletes']: +1936 player_id = int(i['id']) +1937 player_name = i['name'] +1938 player_stat = i['stat'] +1939 +1940 if rebuilt_json.get(player_id) == None: +1941 rebuilt_json[player_id] = {} +1942 +1943 rebuilt_json[player_id]['game_id'] = game_id +1944 rebuilt_json[player_id]['team_name'] = team_name +1945 rebuilt_json[player_id]['team_confrence'] = team_confrence +1946 rebuilt_json[player_id]['player_id'] = player_id +1947 rebuilt_json[player_id]['player_name'] = player_name +1948 rebuilt_json[player_id]['home_away'] = home_away +1949 rebuilt_json[player_id]['passing_C/ATT'] = player_stat +1950 +1951 elif stat['name'] == "YDS": # passing_YDS +1952 +1953 for i in stat['athletes']: +1954 player_id = int(i['id']) +1955 player_name = i['name'] +1956 player_stat = int(i['stat']) +1957 +1958 if rebuilt_json.get(player_id) == None: +1959 rebuilt_json[player_id] = {} +1960 +1961 rebuilt_json[player_id]['game_id'] = game_id +1962 rebuilt_json[player_id]['team_name'] = team_name +1963 rebuilt_json[player_id]['team_confrence'] = team_confrence +1964 rebuilt_json[player_id]['player_id'] = player_id +1965 rebuilt_json[player_id]['player_name'] = player_name +1966 rebuilt_json[player_id]['home_away'] = home_away +1967 rebuilt_json[player_id]['passing_YDS'] = player_stat +1968 +1969 elif stat['name'] == "AVG": # passing_AVG +1970 for i in stat['athletes']: +1971 player_id = int(i['id']) +1972 player_name = i['name'] +1973 player_stat = float(i['stat']) +1974 +1975 if rebuilt_json.get(player_id) == None: +1976 rebuilt_json[player_id] = {} +1977 +1978 rebuilt_json[player_id]['game_id'] = game_id +1979 rebuilt_json[player_id]['team_name'] = team_name +1980 rebuilt_json[player_id]['team_confrence'] = team_confrence +1981 rebuilt_json[player_id]['player_id'] = player_id +1982 rebuilt_json[player_id]['player_name'] = player_name +1983 rebuilt_json[player_id]['home_away'] = home_away +1984 rebuilt_json[player_id]['passing_AVG'] = player_stat +1985 +1986 elif stat['name'] == "TD": # passing_TD +1987 +1988 for i in stat['athletes']: +1989 player_id = int(i['id']) +1990 player_name = i['name'] +1991 player_stat = int(i['stat']) +1992 +1993 if rebuilt_json.get(player_id) == None: +1994 rebuilt_json[player_id] = {} +1995 +1996 rebuilt_json[player_id]['game_id'] = game_id +1997 rebuilt_json[player_id]['team_name'] = team_name +1998 rebuilt_json[player_id]['team_confrence'] = team_confrence +1999 rebuilt_json[player_id]['player_id'] = player_id +2000 rebuilt_json[player_id]['player_name'] = player_name +2001 rebuilt_json[player_id]['home_away'] = home_away +2002 rebuilt_json[player_id]['passing_TD'] = player_stat +2003 +2004 elif stat['name'] == "INT": # passing_INT +2005 +2006 for i in stat['athletes']: +2007 player_id = int(i['id']) +2008 player_name = i['name'] +2009 player_stat = int(i['stat']) +2010 +2011 if rebuilt_json.get(player_id) == None: +2012 rebuilt_json[player_id] = {} +2013 +2014 rebuilt_json[player_id]['game_id'] = game_id +2015 rebuilt_json[player_id]['team_name'] = team_name +2016 rebuilt_json[player_id]['team_confrence'] = team_confrence +2017 rebuilt_json[player_id]['player_id'] = player_id +2018 rebuilt_json[player_id]['player_name'] = player_name +2019 rebuilt_json[player_id]['home_away'] = home_away +2020 rebuilt_json[player_id]['passing_INT'] = player_stat +2021 +2022 elif stat['name'] == "QBR": # passing_QBR +2023 for i in stat['athletes']: +2024 player_id = int(i['id']) +2025 player_name = i['name'] +2026 try: +2027 player_stat = float(i['stat']) +2028 except: +2029 player_stat = None +2030 +2031 if rebuilt_json.get(player_id) == None: +2032 rebuilt_json[player_id] = {} +2033 +2034 rebuilt_json[player_id]['game_id'] = game_id +2035 rebuilt_json[player_id]['team_name'] = team_name +2036 rebuilt_json[player_id]['team_confrence'] = team_confrence +2037 rebuilt_json[player_id]['player_id'] = player_id +2038 rebuilt_json[player_id]['player_name'] = player_name +2039 rebuilt_json[player_id]['home_away'] = home_away +2040 rebuilt_json[player_id]['passing_QBR'] = player_stat +2041 +2042 else: +2043 raise IndexError( +2044 f"Unhandled stat: \t{stat['name']}") +2045 # passing_df = pd.DataFrame(s_category['types']) +2046 elif s_category['name'] == "rushing": +2047 for stat in s_category['types']: +2048 if stat['name'] == "CAR": # rushing_CAR +2049 for i in stat['athletes']: +2050 player_id = int(i['id']) +2051 player_name = i['name'] +2052 player_stat = int(i['stat']) +2053 +2054 if rebuilt_json.get(player_id) == None: +2055 rebuilt_json[player_id] = {} +2056 +2057 rebuilt_json[player_id]['game_id'] = game_id +2058 rebuilt_json[player_id]['team_name'] = team_name +2059 rebuilt_json[player_id]['team_confrence'] = team_confrence +2060 rebuilt_json[player_id]['player_id'] = player_id +2061 rebuilt_json[player_id]['player_name'] = player_name +2062 rebuilt_json[player_id]['home_away'] = home_away +2063 rebuilt_json[player_id]['rushing_CAR'] = player_stat +2064 +2065 elif stat['name'] == "YDS": # rushing_YDS +2066 for i in stat['athletes']: +2067 player_id = int(i['id']) +2068 player_name = i['name'] +2069 player_stat = int(i['stat']) +2070 +2071 if rebuilt_json.get(player_id) == None: +2072 rebuilt_json[player_id] = {} +2073 +2074 rebuilt_json[player_id]['game_id'] = game_id +2075 rebuilt_json[player_id]['team_name'] = team_name +2076 rebuilt_json[player_id]['team_confrence'] = team_confrence +2077 rebuilt_json[player_id]['player_id'] = player_id +2078 rebuilt_json[player_id]['player_name'] = player_name +2079 rebuilt_json[player_id]['home_away'] = home_away +2080 rebuilt_json[player_id]['rushing_YDS'] = player_stat +2081 +2082 elif stat['name'] == "AVG": # rushing_AVG +2083 for i in stat['athletes']: +2084 player_id = int(i['id']) +2085 player_name = i['name'] +2086 player_stat = float(i['stat']) +2087 +2088 if rebuilt_json.get(player_id) == None: +2089 rebuilt_json[player_id] = {} +2090 +2091 rebuilt_json[player_id]['game_id'] = game_id +2092 rebuilt_json[player_id]['team_name'] = team_name +2093 rebuilt_json[player_id]['team_confrence'] = team_confrence +2094 rebuilt_json[player_id]['player_id'] = player_id +2095 rebuilt_json[player_id]['player_name'] = player_name +2096 rebuilt_json[player_id]['home_away'] = home_away +2097 rebuilt_json[player_id]['rushing_AVG'] = player_stat +2098 +2099 elif stat['name'] == "TD": # rushing_TD +2100 for i in stat['athletes']: +2101 player_id = int(i['id']) +2102 player_name = i['name'] +2103 player_stat = int(i['stat']) +2104 +2105 if rebuilt_json.get(player_id) == None: +2106 rebuilt_json[player_id] = {} +2107 +2108 rebuilt_json[player_id]['game_id'] = game_id +2109 rebuilt_json[player_id]['team_name'] = team_name +2110 rebuilt_json[player_id]['team_confrence'] = team_confrence +2111 rebuilt_json[player_id]['player_id'] = player_id +2112 rebuilt_json[player_id]['player_name'] = player_name +2113 rebuilt_json[player_id]['home_away'] = home_away +2114 rebuilt_json[player_id]['rushing_TD'] = player_stat +2115 +2116 elif stat['name'] == "LONG": # rushing_LONG +2117 for i in stat['athletes']: +2118 player_id = int(i['id']) +2119 player_name = i['name'] +2120 player_stat = int(i['stat']) +2121 +2122 if rebuilt_json.get(player_id) == None: +2123 rebuilt_json[player_id] = {} +2124 +2125 rebuilt_json[player_id]['game_id'] = game_id +2126 rebuilt_json[player_id]['team_name'] = team_name +2127 rebuilt_json[player_id]['team_confrence'] = team_confrence +2128 rebuilt_json[player_id]['player_id'] = player_id +2129 rebuilt_json[player_id]['player_name'] = player_name +2130 rebuilt_json[player_id]['home_away'] = home_away +2131 rebuilt_json[player_id]['rushing_LONG'] = player_stat +2132 +2133 else: +2134 raise IndexError( +2135 f"Unhandled stat: \t{stat['name']}") +2136 +2137 elif s_category['name'] == "receiving": +2138 for stat in s_category['types']: +2139 if stat['name'] == "REC": # receiving_REC +2140 for i in stat['athletes']: +2141 player_id = int(i['id']) +2142 player_name = i['name'] +2143 player_stat = int(i['stat']) +2144 +2145 if rebuilt_json.get(player_id) == None: +2146 rebuilt_json[player_id] = {} +2147 +2148 rebuilt_json[player_id]['game_id'] = game_id +2149 rebuilt_json[player_id]['team_name'] = team_name +2150 rebuilt_json[player_id]['team_confrence'] = team_confrence +2151 rebuilt_json[player_id]['player_id'] = player_id +2152 rebuilt_json[player_id]['player_name'] = player_name +2153 rebuilt_json[player_id]['home_away'] = home_away +2154 rebuilt_json[player_id]['receiving_REC'] = player_stat +2155 +2156 elif stat['name'] == "YDS": # receiving_YDS +2157 for i in stat['athletes']: +2158 player_id = int(i['id']) +2159 player_name = i['name'] +2160 player_stat = int(i['stat']) +2161 +2162 if rebuilt_json.get(player_id) == None: +2163 rebuilt_json[player_id] = {} +2164 +2165 rebuilt_json[player_id]['game_id'] = game_id +2166 rebuilt_json[player_id]['team_name'] = team_name +2167 rebuilt_json[player_id]['team_confrence'] = team_confrence +2168 rebuilt_json[player_id]['player_id'] = player_id +2169 rebuilt_json[player_id]['player_name'] = player_name +2170 rebuilt_json[player_id]['home_away'] = home_away +2171 rebuilt_json[player_id]['receiving_YDS'] = player_stat +2172 +2173 elif stat['name'] == "AVG": # receiving_AVG +2174 for i in stat['athletes']: +2175 player_id = int(i['id']) +2176 player_name = i['name'] +2177 player_stat = float(i['stat']) +2178 +2179 if rebuilt_json.get(player_id) == None: +2180 rebuilt_json[player_id] = {} +2181 +2182 rebuilt_json[player_id]['game_id'] = game_id +2183 rebuilt_json[player_id]['team_name'] = team_name +2184 rebuilt_json[player_id]['team_confrence'] = team_confrence +2185 rebuilt_json[player_id]['player_id'] = player_id +2186 rebuilt_json[player_id]['player_name'] = player_name +2187 rebuilt_json[player_id]['home_away'] = home_away +2188 rebuilt_json[player_id]['receiving_AVG'] = player_stat +2189 +2190 elif stat['name'] == "TD": # receiving_TD +2191 for i in stat['athletes']: +2192 player_id = int(i['id']) +2193 player_name = i['name'] +2194 player_stat = int(i['stat']) +2195 +2196 if rebuilt_json.get(player_id) == None: +2197 rebuilt_json[player_id] = {} +2198 +2199 rebuilt_json[player_id]['game_id'] = game_id +2200 rebuilt_json[player_id]['team_name'] = team_name +2201 rebuilt_json[player_id]['team_confrence'] = team_confrence +2202 rebuilt_json[player_id]['player_id'] = player_id +2203 rebuilt_json[player_id]['player_name'] = player_name +2204 rebuilt_json[player_id]['home_away'] = home_away +2205 rebuilt_json[player_id]['receiving_TD'] = player_stat +2206 +2207 elif stat['name'] == "LONG": # receiving_LONG +2208 for i in stat['athletes']: +2209 player_id = int(i['id']) +2210 player_name = i['name'] +2211 player_stat = int(i['stat']) +2212 +2213 if rebuilt_json.get(player_id) == None: +2214 rebuilt_json[player_id] = {} +2215 +2216 rebuilt_json[player_id]['game_id'] = game_id +2217 rebuilt_json[player_id]['team_name'] = team_name +2218 rebuilt_json[player_id]['team_confrence'] = team_confrence +2219 rebuilt_json[player_id]['player_id'] = player_id +2220 rebuilt_json[player_id]['player_name'] = player_name +2221 rebuilt_json[player_id]['home_away'] = home_away +2222 rebuilt_json[player_id]['receiving_LONG'] = player_stat +2223 +2224 else: +2225 raise IndexError( +2226 f"Unhandled stat: \t{stat['name']}") +2227 +2228 elif s_category['name'] == "fumbles": +2229 for stat in s_category['types']: +2230 if stat['name'] == "FUM": # fumbles_FUM +2231 for i in stat['athletes']: +2232 player_id = int(i['id']) +2233 player_name = i['name'] +2234 player_stat = int(i['stat']) +2235 +2236 if rebuilt_json.get(player_id) == None: +2237 rebuilt_json[player_id] = {} +2238 +2239 rebuilt_json[player_id]['game_id'] = game_id +2240 rebuilt_json[player_id]['team_name'] = team_name +2241 rebuilt_json[player_id]['team_confrence'] = team_confrence +2242 rebuilt_json[player_id]['player_id'] = player_id +2243 rebuilt_json[player_id]['player_name'] = player_name +2244 rebuilt_json[player_id]['home_away'] = home_away +2245 rebuilt_json[player_id]['fumbles_FUM'] = player_stat +2246 +2247 elif stat['name'] == "LOST": # fumbles_LOST +2248 for i in stat['athletes']: +2249 player_id = int(i['id']) +2250 player_name = i['name'] +2251 player_stat = int(i['stat']) +2252 +2253 if rebuilt_json.get(player_id) == None: +2254 rebuilt_json[player_id] = {} +2255 +2256 rebuilt_json[player_id]['game_id'] = game_id +2257 rebuilt_json[player_id]['team_name'] = team_name +2258 rebuilt_json[player_id]['team_confrence'] = team_confrence +2259 rebuilt_json[player_id]['player_id'] = player_id +2260 rebuilt_json[player_id]['player_name'] = player_name +2261 rebuilt_json[player_id]['home_away'] = home_away +2262 rebuilt_json[player_id]['fumbles_LOST'] = player_stat +2263 +2264 elif stat['name'] == "REC": # fumbles_REC +2265 for i in stat['athletes']: +2266 player_id = int(i['id']) +2267 player_name = i['name'] +2268 player_stat = int(i['stat']) +2269 +2270 if rebuilt_json.get(player_id) == None: +2271 rebuilt_json[player_id] = {} +2272 +2273 rebuilt_json[player_id]['game_id'] = game_id +2274 rebuilt_json[player_id]['team_name'] = team_name +2275 rebuilt_json[player_id]['team_confrence'] = team_confrence +2276 rebuilt_json[player_id]['player_id'] = player_id +2277 rebuilt_json[player_id]['player_name'] = player_name +2278 rebuilt_json[player_id]['home_away'] = home_away +2279 rebuilt_json[player_id]['fumbles_REC'] = player_stat +2280 +2281 else: +2282 raise IndexError( +2283 f"Unhandled stat: \t{stat['name']}") +2284 +2285 elif s_category['name'] == "defensive": +2286 for stat in s_category['types']: +2287 if stat['name'] == "TOT": # defensive_TOT +2288 for i in stat['athletes']: +2289 player_id = int(i['id']) +2290 player_name = i['name'] +2291 player_stat = int(i['stat']) +2292 +2293 if rebuilt_json.get(player_id) == None: +2294 rebuilt_json[player_id] = {} +2295 +2296 rebuilt_json[player_id]['game_id'] = game_id +2297 rebuilt_json[player_id]['team_name'] = team_name +2298 rebuilt_json[player_id]['team_confrence'] = team_confrence +2299 rebuilt_json[player_id]['player_id'] = player_id +2300 rebuilt_json[player_id]['player_name'] = player_name +2301 rebuilt_json[player_id]['home_away'] = home_away +2302 rebuilt_json[player_id]['defensive_TOT'] = player_stat +2303 +2304 elif stat['name'] == "SOLO": # defensive_SOLO +2305 for i in stat['athletes']: +2306 player_id = int(i['id']) +2307 player_name = i['name'] +2308 player_stat = int(i['stat']) +2309 +2310 if rebuilt_json.get(player_id) == None: +2311 rebuilt_json[player_id] = {} +2312 +2313 rebuilt_json[player_id]['game_id'] = game_id +2314 rebuilt_json[player_id]['team_name'] = team_name +2315 rebuilt_json[player_id]['team_confrence'] = team_confrence +2316 rebuilt_json[player_id]['player_id'] = player_id +2317 rebuilt_json[player_id]['player_name'] = player_name +2318 rebuilt_json[player_id]['home_away'] = home_away +2319 rebuilt_json[player_id]['defensive_SOLO'] = player_stat +2320 +2321 elif stat['name'] == "TFL": # defensive_TFL +2322 for i in stat['athletes']: +2323 player_id = int(i['id']) +2324 player_name = i['name'] +2325 player_stat = float(i['stat']) +2326 +2327 if rebuilt_json.get(player_id) == None: +2328 rebuilt_json[player_id] = {} +2329 +2330 rebuilt_json[player_id]['game_id'] = game_id +2331 rebuilt_json[player_id]['team_name'] = team_name +2332 rebuilt_json[player_id]['team_confrence'] = team_confrence +2333 rebuilt_json[player_id]['player_id'] = player_id +2334 rebuilt_json[player_id]['player_name'] = player_name +2335 rebuilt_json[player_id]['home_away'] = home_away +2336 rebuilt_json[player_id]['defensive_TFL'] = player_stat +2337 +2338 elif stat['name'] == "QB HUR": # defensive_QB HUR +2339 for i in stat['athletes']: +2340 player_id = int(i['id']) +2341 player_name = i['name'] +2342 player_stat = int(i['stat']) +2343 +2344 if rebuilt_json.get(player_id) == None: +2345 rebuilt_json[player_id] = {} +2346 +2347 rebuilt_json[player_id]['game_id'] = game_id +2348 rebuilt_json[player_id]['team_name'] = team_name +2349 rebuilt_json[player_id]['team_confrence'] = team_confrence +2350 rebuilt_json[player_id]['player_id'] = player_id +2351 rebuilt_json[player_id]['player_name'] = player_name +2352 rebuilt_json[player_id]['home_away'] = home_away +2353 rebuilt_json[player_id]['defensive_QB HUR'] = player_stat +2354 +2355 elif stat['name'] == "SACKS": # defensive_SACKS +2356 for i in stat['athletes']: +2357 player_id = int(i['id']) +2358 player_name = i['name'] +2359 player_stat = float(i['stat']) +2360 +2361 if rebuilt_json.get(player_id) == None: +2362 rebuilt_json[player_id] = {} +2363 +2364 rebuilt_json[player_id]['game_id'] = game_id +2365 rebuilt_json[player_id]['team_name'] = team_name +2366 rebuilt_json[player_id]['team_confrence'] = team_confrence +2367 rebuilt_json[player_id]['player_id'] = player_id +2368 rebuilt_json[player_id]['player_name'] = player_name +2369 rebuilt_json[player_id]['home_away'] = home_away +2370 rebuilt_json[player_id]['defensive_SACKS'] = player_stat +2371 +2372 elif stat['name'] == "PD": # defensive_PD +2373 for i in stat['athletes']: +2374 player_id = int(i['id']) +2375 player_name = i['name'] +2376 player_stat = int(i['stat']) +2377 +2378 if rebuilt_json.get(player_id) == None: +2379 rebuilt_json[player_id] = {} +2380 +2381 rebuilt_json[player_id]['game_id'] = game_id +2382 rebuilt_json[player_id]['team_name'] = team_name +2383 rebuilt_json[player_id]['team_confrence'] = team_confrence +2384 rebuilt_json[player_id]['player_id'] = player_id +2385 rebuilt_json[player_id]['player_name'] = player_name +2386 rebuilt_json[player_id]['home_away'] = home_away +2387 rebuilt_json[player_id]['defensive_PD'] = player_stat +2388 +2389 elif stat['name'] == "TD": # defensive_TD +2390 for i in stat['athletes']: +2391 player_id = int(i['id']) +2392 player_name = i['name'] +2393 player_stat = int(i['stat']) +2394 +2395 if rebuilt_json.get(player_id) == None: +2396 rebuilt_json[player_id] = {} +2397 +2398 rebuilt_json[player_id]['game_id'] = game_id +2399 rebuilt_json[player_id]['team_name'] = team_name +2400 rebuilt_json[player_id]['team_confrence'] = team_confrence +2401 rebuilt_json[player_id]['player_id'] = player_id +2402 rebuilt_json[player_id]['player_name'] = player_name +2403 rebuilt_json[player_id]['home_away'] = home_away +2404 rebuilt_json[player_id]['defensive_TD'] = player_stat +2405 +2406 else: +2407 raise IndexError( +2408 f"Unhandled stat: \t{stat['name']}") +2409 +2410 elif s_category['name'] == "interceptions": +2411 for stat in s_category['types']: +2412 if stat['name'] == "INT": # interceptions_INT +2413 for i in stat['athletes']: +2414 player_id = int(i['id']) +2415 player_name = i['name'] +2416 player_stat = int(i['stat']) +2417 +2418 if rebuilt_json.get(player_id) == None: +2419 rebuilt_json[player_id] = {} +2420 +2421 rebuilt_json[player_id]['game_id'] = game_id +2422 rebuilt_json[player_id]['team_name'] = team_name +2423 rebuilt_json[player_id]['team_confrence'] = team_confrence +2424 rebuilt_json[player_id]['player_id'] = player_id +2425 rebuilt_json[player_id]['player_name'] = player_name +2426 rebuilt_json[player_id]['home_away'] = home_away +2427 rebuilt_json[player_id]['interceptions_INT'] = player_stat +2428 +2429 elif stat['name'] == "YDS": # interceptions_YDS +2430 for i in stat['athletes']: +2431 player_id = int(i['id']) +2432 player_name = i['name'] +2433 player_stat = int(i['stat']) +2434 +2435 if rebuilt_json.get(player_id) == None: +2436 rebuilt_json[player_id] = {} +2437 +2438 rebuilt_json[player_id]['game_id'] = game_id +2439 rebuilt_json[player_id]['team_name'] = team_name +2440 rebuilt_json[player_id]['team_confrence'] = team_confrence +2441 rebuilt_json[player_id]['player_id'] = player_id +2442 rebuilt_json[player_id]['player_name'] = player_name +2443 rebuilt_json[player_id]['home_away'] = home_away +2444 rebuilt_json[player_id]['interceptions_YDS'] = player_stat +2445 +2446 elif stat['name'] == "TD": # interceptions_TD +2447 for i in stat['athletes']: +2448 player_id = int(i['id']) +2449 player_name = i['name'] +2450 player_stat = int(i['stat']) +2451 +2452 if rebuilt_json.get(player_id) == None: +2453 rebuilt_json[player_id] = {} +2454 +2455 rebuilt_json[player_id]['game_id'] = game_id +2456 rebuilt_json[player_id]['team_name'] = team_name +2457 rebuilt_json[player_id]['team_confrence'] = team_confrence +2458 rebuilt_json[player_id]['player_id'] = player_id +2459 rebuilt_json[player_id]['player_name'] = player_name +2460 rebuilt_json[player_id]['home_away'] = home_away +2461 rebuilt_json[player_id]['interceptions_TD'] = player_stat +2462 +2463 else: +2464 raise IndexError( +2465 f"Unhandled stat: \t{stat['name']}") +2466 +2467 elif s_category['name'] == "punting": +2468 for stat in s_category['types']: +2469 if stat['name'] == "NO": # punting_NO +2470 for i in stat['athletes']: +2471 player_id = int(i['id']) +2472 player_name = i['name'] +2473 player_stat = int(i['stat']) +2474 +2475 if rebuilt_json.get(player_id) == None: +2476 rebuilt_json[player_id] = {} +2477 +2478 rebuilt_json[player_id]['game_id'] = game_id +2479 rebuilt_json[player_id]['team_name'] = team_name +2480 rebuilt_json[player_id]['team_confrence'] = team_confrence +2481 rebuilt_json[player_id]['player_id'] = player_id +2482 rebuilt_json[player_id]['player_name'] = player_name +2483 rebuilt_json[player_id]['home_away'] = home_away +2484 rebuilt_json[player_id]['punting_NO'] = player_stat +2485 +2486 elif stat['name'] == "YDS": # punting_YDS +2487 for i in stat['athletes']: +2488 player_id = int(i['id']) +2489 player_name = i['name'] +2490 player_stat = int(i['stat']) +2491 +2492 if rebuilt_json.get(player_id) == None: +2493 rebuilt_json[player_id] = {} +2494 +2495 rebuilt_json[player_id]['game_id'] = game_id +2496 rebuilt_json[player_id]['team_name'] = team_name +2497 rebuilt_json[player_id]['team_confrence'] = team_confrence +2498 rebuilt_json[player_id]['player_id'] = player_id +2499 rebuilt_json[player_id]['player_name'] = player_name +2500 rebuilt_json[player_id]['home_away'] = home_away +2501 rebuilt_json[player_id]['punting_YDS'] = player_stat +2502 +2503 elif stat['name'] == "AVG": # punting_AVG +2504 for i in stat['athletes']: +2505 player_id = int(i['id']) +2506 player_name = i['name'] +2507 player_stat = float(i['stat']) +2508 +2509 if rebuilt_json.get(player_id) == None: +2510 rebuilt_json[player_id] = {} +2511 +2512 rebuilt_json[player_id]['game_id'] = game_id +2513 rebuilt_json[player_id]['team_name'] = team_name +2514 rebuilt_json[player_id]['team_confrence'] = team_confrence +2515 rebuilt_json[player_id]['player_id'] = player_id +2516 rebuilt_json[player_id]['player_name'] = player_name +2517 rebuilt_json[player_id]['home_away'] = home_away +2518 rebuilt_json[player_id]['punting_AVG'] = player_stat +2519 +2520 elif stat['name'] == "TB": # punting_TB +2521 for i in stat['athletes']: +2522 player_id = int(i['id']) +2523 player_name = i['name'] +2524 player_stat = int(i['stat']) +2525 +2526 if rebuilt_json.get(player_id) == None: +2527 rebuilt_json[player_id] = {} +2528 +2529 rebuilt_json[player_id]['game_id'] = game_id +2530 rebuilt_json[player_id]['team_name'] = team_name +2531 rebuilt_json[player_id]['team_confrence'] = team_confrence +2532 rebuilt_json[player_id]['player_id'] = player_id +2533 rebuilt_json[player_id]['player_name'] = player_name +2534 rebuilt_json[player_id]['home_away'] = home_away +2535 rebuilt_json[player_id]['punting_TB'] = player_stat +2536 +2537 elif stat['name'] == "In 20": # punting_In 20 +2538 for i in stat['athletes']: +2539 player_id = int(i['id']) +2540 player_name = i['name'] +2541 player_stat = int(i['stat']) +2542 +2543 if rebuilt_json.get(player_id) == None: +2544 rebuilt_json[player_id] = {} +2545 +2546 rebuilt_json[player_id]['game_id'] = game_id +2547 rebuilt_json[player_id]['team_name'] = team_name +2548 rebuilt_json[player_id]['team_confrence'] = team_confrence +2549 rebuilt_json[player_id]['player_id'] = player_id +2550 rebuilt_json[player_id]['player_name'] = player_name +2551 rebuilt_json[player_id]['home_away'] = home_away +2552 rebuilt_json[player_id]['punting_In 20'] = player_stat +2553 +2554 elif stat['name'] == "LONG": # punting_LONG +2555 for i in stat['athletes']: +2556 player_id = int(i['id']) +2557 player_name = i['name'] +2558 player_stat = int(i['stat']) +2559 +2560 if rebuilt_json.get(player_id) == None: +2561 rebuilt_json[player_id] = {} +2562 +2563 rebuilt_json[player_id]['game_id'] = game_id +2564 rebuilt_json[player_id]['team_name'] = team_name +2565 rebuilt_json[player_id]['team_confrence'] = team_confrence +2566 rebuilt_json[player_id]['player_id'] = player_id +2567 rebuilt_json[player_id]['player_name'] = player_name +2568 rebuilt_json[player_id]['home_away'] = home_away +2569 rebuilt_json[player_id]['punting_LONG'] = player_stat +2570 +2571 else: +2572 raise IndexError( +2573 f"Unhandled stat: \t{stat['name']}") +2574 +2575 elif s_category['name'] == "kicking": +2576 for stat in s_category['types']: +2577 if stat['name'] == "FG": # kicking_FG +2578 for i in stat['athletes']: +2579 player_id = int(i['id']) +2580 player_name = i['name'] +2581 player_stat = i['stat'] +2582 +2583 if rebuilt_json.get(player_id) == None: +2584 rebuilt_json[player_id] = {} +2585 +2586 rebuilt_json[player_id]['game_id'] = game_id +2587 rebuilt_json[player_id]['team_name'] = team_name +2588 rebuilt_json[player_id]['team_confrence'] = team_confrence +2589 rebuilt_json[player_id]['player_id'] = player_id +2590 rebuilt_json[player_id]['player_name'] = player_name +2591 rebuilt_json[player_id]['home_away'] = home_away +2592 rebuilt_json[player_id]['kicking_FG'] = player_stat +2593 +2594 elif stat['name'] == "TOT": # kicking_FG, special case +2595 for i in stat['athletes']: +2596 player_id = int(i['id']) +2597 player_name = i['name'] +2598 player_stat = i['stat'] +2599 +2600 if rebuilt_json.get(player_id) == None: +2601 rebuilt_json[player_id] = {} +2602 +2603 rebuilt_json[player_id]['game_id'] = game_id +2604 rebuilt_json[player_id]['team_name'] = team_name +2605 rebuilt_json[player_id]['team_confrence'] = team_confrence +2606 rebuilt_json[player_id]['player_id'] = player_id +2607 rebuilt_json[player_id]['player_name'] = player_name +2608 rebuilt_json[player_id]['home_away'] = home_away +2609 rebuilt_json[player_id]['kicking_FG'] = player_stat +2610 +2611 elif stat['name'] == "PCT": # kicking_PCT +2612 for i in stat['athletes']: +2613 player_id = int(i['id']) +2614 player_name = i['name'] +2615 player_stat = float(i['stat']) +2616 +2617 if rebuilt_json.get(player_id) == None: +2618 rebuilt_json[player_id] = {} +2619 +2620 rebuilt_json[player_id]['game_id'] = game_id +2621 rebuilt_json[player_id]['team_name'] = team_name +2622 rebuilt_json[player_id]['team_confrence'] = team_confrence +2623 rebuilt_json[player_id]['player_id'] = player_id +2624 rebuilt_json[player_id]['player_name'] = player_name +2625 rebuilt_json[player_id]['home_away'] = home_away +2626 rebuilt_json[player_id]['kicking_PCT'] = player_stat +2627 +2628 elif stat['name'] == "LONG": # kicking_LONG +2629 for i in stat['athletes']: +2630 player_id = int(i['id']) +2631 player_name = i['name'] +2632 player_stat = int(i['stat']) +2633 +2634 if rebuilt_json.get(player_id) == None: +2635 rebuilt_json[player_id] = {} +2636 +2637 rebuilt_json[player_id]['game_id'] = game_id +2638 rebuilt_json[player_id]['team_name'] = team_name +2639 rebuilt_json[player_id]['team_confrence'] = team_confrence +2640 rebuilt_json[player_id]['player_id'] = player_id +2641 rebuilt_json[player_id]['player_name'] = player_name +2642 rebuilt_json[player_id]['home_away'] = home_away +2643 rebuilt_json[player_id]['kicking_LONG'] = player_stat +2644 +2645 elif stat['name'] == "XP": # kicking_XP +2646 for i in stat['athletes']: +2647 player_id = int(i['id']) +2648 player_name = i['name'] +2649 player_stat = i['stat'] +2650 +2651 if rebuilt_json.get(player_id) == None: +2652 rebuilt_json[player_id] = {} +2653 +2654 rebuilt_json[player_id]['game_id'] = game_id +2655 rebuilt_json[player_id]['team_name'] = team_name +2656 rebuilt_json[player_id]['team_confrence'] = team_confrence +2657 rebuilt_json[player_id]['player_id'] = player_id +2658 rebuilt_json[player_id]['player_name'] = player_name +2659 rebuilt_json[player_id]['home_away'] = home_away +2660 rebuilt_json[player_id]['kicking_XP'] = player_stat +2661 +2662 elif stat['name'] == "PTS": # kicking_PTS +2663 for i in stat['athletes']: +2664 player_id = int(i['id']) +2665 player_name = i['name'] +2666 player_stat = int(i['stat']) +2667 +2668 if rebuilt_json.get(player_id) == None: +2669 rebuilt_json[player_id] = {} +2670 +2671 rebuilt_json[player_id]['game_id'] = game_id +2672 rebuilt_json[player_id]['team_name'] = team_name +2673 rebuilt_json[player_id]['team_confrence'] = team_confrence +2674 rebuilt_json[player_id]['player_id'] = player_id +2675 rebuilt_json[player_id]['player_name'] = player_name +2676 rebuilt_json[player_id]['home_away'] = home_away +2677 rebuilt_json[player_id]['kicking_PTS'] = player_stat +2678 +2679 else: +2680 raise IndexError( +2681 f"Unhandled stat: \t{stat['name']}") +2682 +2683 elif s_category['name'] == "kickReturns": +2684 for stat in s_category['types']: +2685 if stat['name'] == "NO": # kickReturns_NO +2686 for i in stat['athletes']: +2687 player_id = int(i['id']) +2688 player_name = i['name'] +2689 player_stat = int(i['stat']) +2690 +2691 if rebuilt_json.get(player_id) == None: +2692 rebuilt_json[player_id] = {} +2693 +2694 rebuilt_json[player_id]['game_id'] = game_id +2695 rebuilt_json[player_id]['team_name'] = team_name +2696 rebuilt_json[player_id]['team_confrence'] = team_confrence +2697 rebuilt_json[player_id]['player_id'] = player_id +2698 rebuilt_json[player_id]['player_name'] = player_name +2699 rebuilt_json[player_id]['home_away'] = home_away +2700 rebuilt_json[player_id]['kickReturns_NO'] = player_stat +2701 +2702 elif stat['name'] == "YDS": # kickReturns_YDS +2703 for i in stat['athletes']: +2704 player_id = int(i['id']) +2705 player_name = i['name'] +2706 player_stat = int(i['stat']) +2707 +2708 if rebuilt_json.get(player_id) == None: +2709 rebuilt_json[player_id] = {} +2710 +2711 rebuilt_json[player_id]['game_id'] = game_id +2712 rebuilt_json[player_id]['team_name'] = team_name +2713 rebuilt_json[player_id]['team_confrence'] = team_confrence +2714 rebuilt_json[player_id]['player_id'] = player_id +2715 rebuilt_json[player_id]['player_name'] = player_name +2716 rebuilt_json[player_id]['home_away'] = home_away +2717 rebuilt_json[player_id]['kickReturns_YDS'] = player_stat +2718 +2719 elif stat['name'] == "AVG": # kickReturns_AVG +2720 for i in stat['athletes']: +2721 player_id = int(i['id']) +2722 player_name = i['name'] +2723 player_stat = float(i['stat']) +2724 +2725 if rebuilt_json.get(player_id) == None: +2726 rebuilt_json[player_id] = {} +2727 +2728 rebuilt_json[player_id]['game_id'] = game_id +2729 rebuilt_json[player_id]['team_name'] = team_name +2730 rebuilt_json[player_id]['team_confrence'] = team_confrence +2731 rebuilt_json[player_id]['player_id'] = player_id +2732 rebuilt_json[player_id]['player_name'] = player_name +2733 rebuilt_json[player_id]['home_away'] = home_away +2734 rebuilt_json[player_id]['kickReturns_AVG'] = player_stat +2735 +2736 elif stat['name'] == "TD": # kickReturns_TD +2737 for i in stat['athletes']: +2738 player_id = int(i['id']) +2739 player_name = i['name'] +2740 player_stat = int(i['stat']) +2741 +2742 if rebuilt_json.get(player_id) == None: +2743 rebuilt_json[player_id] = {} +2744 +2745 rebuilt_json[player_id]['game_id'] = game_id +2746 rebuilt_json[player_id]['team_name'] = team_name +2747 rebuilt_json[player_id]['team_confrence'] = team_confrence +2748 rebuilt_json[player_id]['player_id'] = player_id +2749 rebuilt_json[player_id]['player_name'] = player_name +2750 rebuilt_json[player_id]['home_away'] = home_away +2751 rebuilt_json[player_id]['kickReturns_TD'] = player_stat +2752 +2753 elif stat['name'] == "LONG": # kickReturns_LONG +2754 for i in stat['athletes']: +2755 player_id = int(i['id']) +2756 player_name = i['name'] +2757 player_stat = int(i['stat']) +2758 +2759 if rebuilt_json.get(player_id) == None: +2760 rebuilt_json[player_id] = {} +2761 +2762 rebuilt_json[player_id]['game_id'] = game_id +2763 rebuilt_json[player_id]['team_name'] = team_name +2764 rebuilt_json[player_id]['team_confrence'] = team_confrence +2765 rebuilt_json[player_id]['player_id'] = player_id +2766 rebuilt_json[player_id]['player_name'] = player_name +2767 rebuilt_json[player_id]['home_away'] = home_away +2768 rebuilt_json[player_id]['kickReturns_LONG'] = player_stat +2769 +2770 else: +2771 raise IndexError( +2772 f"Unhandled stat: \t{stat['name']}") +2773 +2774 elif s_category['name'] == "puntReturns": +2775 for stat in s_category['types']: +2776 if stat['name'] == "NO": # puntReturns_NO +2777 for i in stat['athletes']: +2778 player_id = int(i['id']) +2779 player_name = i['name'] +2780 player_stat = int(i['stat']) +2781 +2782 if rebuilt_json.get(player_id) == None: +2783 rebuilt_json[player_id] = {} +2784 +2785 rebuilt_json[player_id]['game_id'] = game_id +2786 rebuilt_json[player_id]['team_name'] = team_name +2787 rebuilt_json[player_id]['team_confrence'] = team_confrence +2788 rebuilt_json[player_id]['player_id'] = player_id +2789 rebuilt_json[player_id]['player_name'] = player_name +2790 rebuilt_json[player_id]['home_away'] = home_away +2791 rebuilt_json[player_id]['puntReturns_NO'] = player_stat +2792 +2793 elif stat['name'] == "YDS": # puntReturns_YDS +2794 for i in stat['athletes']: +2795 player_id = int(i['id']) +2796 player_name = i['name'] +2797 player_stat = int(i['stat']) +2798 +2799 if rebuilt_json.get(player_id) == None: +2800 rebuilt_json[player_id] = {} +2801 +2802 rebuilt_json[player_id]['game_id'] = game_id +2803 rebuilt_json[player_id]['team_name'] = team_name +2804 rebuilt_json[player_id]['team_confrence'] = team_confrence +2805 rebuilt_json[player_id]['player_id'] = player_id +2806 rebuilt_json[player_id]['player_name'] = player_name +2807 rebuilt_json[player_id]['home_away'] = home_away +2808 rebuilt_json[player_id]['puntReturns_YDS'] = player_stat +2809 +2810 elif stat['name'] == "AVG": # puntReturns_AVG +2811 for i in stat['athletes']: +2812 player_id = int(i['id']) +2813 player_name = i['name'] +2814 player_stat = float(i['stat']) +2815 +2816 if rebuilt_json.get(player_id) == None: +2817 rebuilt_json[player_id] = {} +2818 +2819 rebuilt_json[player_id]['game_id'] = game_id +2820 rebuilt_json[player_id]['team_name'] = team_name +2821 rebuilt_json[player_id]['team_confrence'] = team_confrence +2822 rebuilt_json[player_id]['player_id'] = player_id +2823 rebuilt_json[player_id]['player_name'] = player_name +2824 rebuilt_json[player_id]['home_away'] = home_away +2825 rebuilt_json[player_id]['puntReturns_AVG'] = player_stat +2826 +2827 elif stat['name'] == "TD": # puntReturns_TD +2828 for i in stat['athletes']: +2829 player_id = int(i['id']) +2830 player_name = i['name'] +2831 player_stat = int(i['stat']) +2832 +2833 if rebuilt_json.get(player_id) == None: +2834 rebuilt_json[player_id] = {} +2835 +2836 rebuilt_json[player_id]['game_id'] = game_id +2837 rebuilt_json[player_id]['team_name'] = team_name +2838 rebuilt_json[player_id]['team_confrence'] = team_confrence +2839 rebuilt_json[player_id]['player_id'] = player_id +2840 rebuilt_json[player_id]['player_name'] = player_name +2841 rebuilt_json[player_id]['home_away'] = home_away +2842 rebuilt_json[player_id]['puntReturns_TD'] = player_stat +2843 +2844 elif stat['name'] == "LONG": # puntReturns_LONG +2845 for i in stat['athletes']: +2846 player_id = int(i['id']) +2847 player_name = i['name'] +2848 player_stat = int(i['stat']) +2849 +2850 if rebuilt_json.get(player_id) == None: +2851 rebuilt_json[player_id] = {} +2852 +2853 rebuilt_json[player_id]['game_id'] = game_id +2854 rebuilt_json[player_id]['team_name'] = team_name +2855 rebuilt_json[player_id]['team_confrence'] = team_confrence +2856 rebuilt_json[player_id]['player_id'] = player_id +2857 rebuilt_json[player_id]['player_name'] = player_name +2858 rebuilt_json[player_id]['home_away'] = home_away +2859 rebuilt_json[player_id]['puntReturns_LONG'] = player_stat +2860 +2861 else: +2862 raise IndexError( +2863 f"Unhandled stat: \t{stat['name']}") +2864 +2865 else: +2866 raise IndexError( +2867 f"Unhandled stat category: \t{s_category['name']}" +2868 ) +2869 +2870 for key, value in tqdm(rebuilt_json.items()): +2871 # print(key) +2872 +2873 # print(value) +2874 game_id = value['game_id'] +2875 team_name = value['team_name'] +2876 team_confrence = value['team_confrence'] +2877 player_id = value['player_id'] +2878 player_name = value['player_name'] +2879 home_away = value['home_away'] +2880 +2881 row_df = pd.DataFrame( +2882 { +2883 "game_id": game_id, +2884 "team_name": team_name, +2885 "team_confrence": team_confrence, +2886 "player_id": player_id, +2887 "player_name": player_name, +2888 "home_away": home_away +2889 }, +2890 index=[0] +2891 ) +2892 # Passing +2893 if value.get('passing_C/ATT') != None: +2894 row_df['passing_C/ATT'] = value['passing_C/ATT'] +2895 +2896 if value.get('passing_YDS') != None: +2897 row_df['passing_YDS'] = value['passing_YDS'] +2898 +2899 if value.get('passing_AVG') != None: +2900 row_df['passing_AVG'] = value['passing_AVG'] +2901 +2902 if value.get('passing_TD') != None: +2903 row_df['passing_TD'] = value['passing_TD'] +2904 +2905 if value.get('passing_INT') != None: +2906 row_df['passing_INT'] = value['passing_INT'] +2907 +2908 if value.get('passing_QBR') != None: +2909 row_df['passing_QBR'] = value['passing_QBR'] +2910 +2911 # Rushing +2912 if value.get('rushing_CAR') != None: +2913 row_df['rushing_CAR'] = value['rushing_CAR'] +2914 +2915 if value.get('rushing_YDS') != None: +2916 row_df['rushing_YDS'] = value['rushing_YDS'] +2917 +2918 if value.get('rushing_AVG') != None: +2919 row_df['rushing_AVG'] = value['rushing_AVG'] +2920 +2921 if value.get('rushing_TD') != None: +2922 row_df['rushing_TD'] = value['rushing_TD'] +2923 +2924 if value.get('rushing_LONG') != None: +2925 row_df['rushing_LONG'] = value['rushing_LONG'] +2926 +2927 # Receiving +2928 if value.get('receiving_REC') != None: +2929 row_df['receiving_REC'] = value['receiving_REC'] +2930 +2931 if value.get('receiving_YDS') != None: +2932 row_df['receiving_YDS'] = value['receiving_YDS'] +2933 +2934 if value.get('receiving_AVG') != None: +2935 row_df['receiving_AVG'] = value['receiving_AVG'] +2936 +2937 if value.get('receiving_TD') != None: +2938 row_df['receiving_TD'] = value['receiving_TD'] +2939 +2940 if value.get('receiving_LONG') != None: +2941 row_df['receiving_LONG'] = value['receiving_LONG'] +2942 +2943 # Fumbles +2944 if value.get('fumbles_FUM') != None: +2945 row_df['fumbles_FUM'] = value['fumbles_FUM'] +2946 +2947 if value.get('fumbles_LOST') != None: +2948 row_df['fumbles_LOST'] = value['fumbles_LOST'] +2949 +2950 if value.get('fumbles_REC') != None: +2951 row_df['fumbles_REC'] = value['fumbles_REC'] +2952 +2953 # Defense +2954 if value.get('defensive_TOT') != None: +2955 row_df['defensive_TOT'] = value['defensive_TOT'] +2956 +2957 if value.get('defensive_SOLO') != None: +2958 row_df['defensive_SOLO'] = value['defensive_SOLO'] +2959 +2960 if value.get('defensive_TFL') != None: +2961 row_df['defensive_TFL'] = value['defensive_TFL'] +2962 +2963 if value.get('defensive_QB HUR') != None: +2964 row_df['defensive_QB HUR'] = value['defensive_QB HUR'] +2965 +2966 if value.get('defensive_SACKS') != None: +2967 row_df['defensive_SACKS'] = value['defensive_SACKS'] +2968 +2969 if value.get('defensive_PD') != None: +2970 row_df['defensive_PD'] = value['defensive_PD'] +2971 +2972 if value.get('defensive_TD') != None: +2973 row_df['defensive_TD'] = value['defensive_TD'] +2974 +2975 # interceptions +2976 if value.get('interceptions_INT') != None: +2977 row_df['interceptions_INT'] = value['interceptions_INT'] +2978 +2979 if value.get('interceptions_YDS') != None: +2980 row_df['interceptions_YDS'] = value['interceptions_YDS'] +2981 +2982 if value.get('interceptions_TD') != None: +2983 row_df['interceptions_TD'] = value['interceptions_TD'] +2984 +2985 # punting +2986 if value.get('punting_NO') != None: +2987 row_df['punting_NO'] = value['punting_NO'] +2988 +2989 if value.get('punting_YDS') != None: +2990 row_df['punting_YDS'] = value['punting_YDS'] +2991 +2992 if value.get('punting_AVG') != None: +2993 row_df['punting_AVG'] = value['punting_AVG'] +2994 +2995 if value.get('punting_TB') != None: +2996 row_df['punting_TB'] = value['punting_TB'] +2997 +2998 if value.get('punting_In 20') != None: +2999 row_df['punting_In 20'] = value['punting_In 20'] +3000 +3001 if value.get('punting_LONG') != None: +3002 row_df['punting_LONG'] = value['punting_LONG'] +3003 +3004 # kicking +3005 if value.get('kicking_FG') != None: +3006 row_df['kicking_FG'] = value['kicking_FG'] +3007 +3008 if value.get('kicking_PCT') != None: +3009 row_df['kicking_PCT'] = value['kicking_PCT'] +3010 +3011 if value.get('kicking_LONG') != None: +3012 row_df['kicking_LONG'] = value['kicking_LONG'] +3013 +3014 if value.get('kicking_XP') != None: +3015 row_df['kicking_XP'] = value['kicking_XP'] +3016 +3017 if value.get('kicking_PTS') != None: +3018 row_df['kicking_PTS'] = value['kicking_PTS'] +3019 +3020 # kickReturns +3021 if value.get('kickReturns_NO') != None: +3022 row_df['kickReturns_NO'] = value['kickReturns_NO'] +3023 +3024 if value.get('kickReturns_YDS') != None: +3025 row_df['kickReturns_YDS'] = value['kickReturns_YDS'] +3026 +3027 if value.get('kickReturns_AVG') != None: +3028 row_df['kickReturns_AVG'] = value['kickReturns_AVG'] +3029 +3030 if value.get('kickReturns_TD') != None: +3031 row_df['kickReturns_TD'] = value['kickReturns_TD'] +3032 +3033 if value.get('kickReturns_LONG') != None: +3034 row_df['kickReturns_LONG'] = value['kickReturns_LONG'] +3035 +3036 # puntReturns +3037 if value.get('puntReturns_NO') != None: +3038 row_df['puntReturns_NO'] = value['puntReturns_NO'] +3039 +3040 if value.get('puntReturns_YDS') != None: +3041 row_df['puntReturns_YDS'] = value['puntReturns_YDS'] +3042 +3043 if value.get('puntReturns_AVG') != None: +3044 row_df['puntReturns_AVG'] = value['puntReturns_AVG'] +3045 +3046 if value.get('puntReturns_TD') != None: +3047 row_df['puntReturns_TD'] = value['puntReturns_TD'] +3048 +3049 if value.get('puntReturns_LONG') != None: +3050 row_df['puntReturns_LONG'] = value['puntReturns_LONG'] +3051 +3052 cfb_games_df = pd.concat([cfb_games_df, row_df], ignore_index=True) +3053 del row_df +3054 +3055 cfb_games_df[['passing_COMP', 'passing_ATT'] +3056 ] = cfb_games_df['passing_C/ATT'].str.split('/', expand=True) +3057 +3058 cfb_games_df[['kicking_FGM', 'kicking_FGA'] +3059 ] = cfb_games_df['kicking_FG'].str.split('/', expand=True) +3060 cfb_games_df[['kicking_XPM', 'kicking_XPA'] +3061 ] = cfb_games_df['kicking_XP'].str.split('/', expand=True) +3062 +3063 cfb_games_df = cfb_games_df.fillna(0) +3064 +3065 cfb_games_df = cfb_games_df.astype({ +3066 "passing_COMP": "int", +3067 "passing_ATT": "int", +3068 "kicking_FGM": "int", +3069 "kicking_FGA": "int", +3070 "kicking_XPM": "int", +3071 "kicking_XPA": "int" +3072 }) +3073 # print(cfb_games_df.columns) +3074 cfb_games_df['season'] = season +3075 +3076 if filter_by_stat_category == False: +3077 cfb_games_df = cfb_games_df.reindex(columns=stat_columns) +3078 +3079 elif filter_by_stat_category == True and stat_category == "passing": +3080 cfb_games_df = cfb_games_df[[ +3081 'season', +3082 'game_id', +3083 'team_name', +3084 'team_confrence', +3085 'player_id', +3086 'player_name', +3087 'home_away', +3088 # PASS +3089 'passing_C/ATT', +3090 'passing_COMP', +3091 'passing_ATT', +3092 'passing_YDS', +3093 'passing_AVG', +3094 'passing_TD', +3095 'passing_INT', +3096 'passing_QBR' +3097 ]] +3098 +3099 elif filter_by_stat_category == True and stat_category == "rushing": +3100 cfb_games_df = cfb_games_df[[ +3101 'season', +3102 'game_id', +3103 'team_name', +3104 'team_confrence', +3105 'player_id', +3106 'player_name', +3107 'home_away', +3108 # RUSH +3109 'rushing_CAR', +3110 'rushing_YDS', +3111 'rushing_AVG', +3112 'rushing_TD', +3113 'rushing_LONG', +3114 ]] +3115 +3116 elif filter_by_stat_category == True and stat_category == "receiving": +3117 cfb_games_df = cfb_games_df[[ +3118 'season', +3119 'game_id', +3120 'team_name', +3121 'team_confrence', +3122 'player_id', +3123 'player_name', +3124 'home_away', +3125 # REC +3126 'receiving_REC', +3127 'receiving_YDS', +3128 'receiving_AVG', +3129 'receiving_TD', +3130 'receiving_LONG' +3131 ]] +3132 +3133 elif filter_by_stat_category == True and stat_category == "fumbles": +3134 cfb_games_df = cfb_games_df[[ +3135 'season', +3136 'game_id', +3137 'team_name', +3138 'team_confrence', +3139 'player_id', +3140 'player_name', +3141 'home_away', +3142 # FUM +3143 'fumbles_FUM', +3144 'fumbles_LOST', +3145 'fumbles_REC' +3146 ]] +3147 +3148 elif filter_by_stat_category == True and stat_category == "defensive": +3149 cfb_games_df = cfb_games_df[[ +3150 'season', +3151 'game_id', +3152 'team_name', +3153 'team_confrence', +3154 'player_id', +3155 'player_name', +3156 'home_away', +3157 # DEFENSE +3158 'defensive_TOT', +3159 'defensive_SOLO', +3160 'defensive_TFL', +3161 'defensive_QB HUR', +3162 'defensive_SACKS', +3163 'defensive_PD', +3164 'defensive_TD' +3165 ]] +3166 +3167 elif filter_by_stat_category == True and stat_category == "interceptions": +3168 cfb_games_df = cfb_games_df[[ +3169 'season', +3170 'game_id', +3171 'team_name', +3172 'team_confrence', +3173 'player_id', +3174 'player_name', +3175 'home_away', +3176 # INT +3177 'interceptions_INT', +3178 'interceptions_YDS', +3179 'interceptions_TD', +3180 ]] +3181 +3182 elif filter_by_stat_category == True and stat_category == "punting": +3183 cfb_games_df = cfb_games_df[[ +3184 'season', +3185 'game_id', +3186 'team_name', +3187 'team_confrence', +3188 'player_id', +3189 'player_name', +3190 'home_away', +3191 # PUNT +3192 'punting_NO', +3193 'punting_YDS', +3194 'punting_AVG', +3195 'punting_TB', +3196 'punting_In 20', +3197 'punting_LONG' +3198 ]] +3199 +3200 elif filter_by_stat_category == True and stat_category == "kicking": +3201 cfb_games_df = cfb_games_df[[ +3202 'season', +3203 'game_id', +3204 'team_name', +3205 'team_confrence', +3206 'player_id', +3207 'player_name', +3208 'home_away', +3209 # KICK +3210 'kicking_FG', +3211 'kicking_FGM', +3212 'kicking_FGA', +3213 'kicking_PCT', +3214 'kicking_LONG', +3215 'kicking_XP', +3216 'kicking_XPM', +3217 'kicking_XPA', +3218 'kicking_PTS' +3219 ]] +3220 +3221 elif filter_by_stat_category == True and stat_category == "kickReturns": +3222 cfb_games_df = cfb_games_df[[ +3223 'season', +3224 'game_id', +3225 'team_name', +3226 'team_confrence', +3227 'player_id', +3228 'player_name', +3229 'home_away', +3230 # KR +3231 'kickReturns_NO', +3232 'kickReturns_YDS', +3233 'kickReturns_AVG', +3234 'kickReturns_TD', +3235 'kickReturns_LONG' +3236 ]] +3237 +3238 elif filter_by_stat_category == True and stat_category == "puntReturns": +3239 cfb_games_df = cfb_games_df[[ +3240 'season', +3241 'game_id', +3242 'team_name', +3243 'team_confrence', +3244 'player_id', +3245 'player_name', +3246 'home_away', +3247 # KR +3248 'puntReturns_NO', +3249 'puntReturns_YDS', +3250 'puntReturns_AVG', +3251 'puntReturns_TD', +3252 'puntReturns_LONG' +3253 ]] +3254 +3255 return cfb_games_df

@@ -7764,9 +7788,9 @@

Parameters

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. @@ -7787,7 +7811,7 @@

Parameters

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.

@@ -7798,20 +7822,20 @@

Parameters

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. @@ -8027,256 +8051,256 @@

Returns

-
3246def get_cfbd_player_advanced_game_stats(
-3247        game_id: int,
-3248        api_key: str = None,
-3249        api_key_dir: str = None,
-3250        return_as_dict: bool = False):
-3251    """
-3252    Retrives advanced game stats from the CFBD API.
-3253
-3254    Parameters
-3255    ----------
-3256
-3257    `api_key` (str, optional):
-3258        Semi-optional argument. 
-3259        If `api_key` is null, this function will attempt to load a CFBD API key
-3260        from the python environment, or from a file on this computer.
-3261        If `api_key` is not null, this function will automatically assume that the
-3262        inputted `api_key` is a valid CFBD API key.
-3263
-3264    `api_key_dir` (str, optional):
-3265        Optional argument.
-3266        If `api_key` is set to am empty string, this variable is ignored.
-3267        If `api_key_dir` is null, and `api_key` is null, 
-3268        this function will try to find a CFBD API key file in this user's home directory.
-3269        If `api_key_dir` is set to a string, and `api_key` is null,
-3270        this function will assume that `api_key_dir` is a directory, 
-3271        and will try to find a CFBD API key file in that directory.
-3272    
-3273    `return_as_dict` (bool, semi-optional):
-3274        Semi-optional argument.
-3275        If you want this function to return the data as a dictionary (read: JSON object), 
-3276        instead of a pandas `DataFrame` object,
-3277        set `return_as_dict` to `True`.
-3278
-3279    Usage
-3280    ----------
-3281    ```
-3282    import time
-3283
-3284    from cfbd_json_py.games import get_cfbd_player_advanced_game_stats
-3285
-3286
-3287    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
-3288
-3289    if cfbd_key != "tigersAreAwsome":
-3290        print("Using the user's API key declared in this script for this example.")
-3291
-3292        # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, 
-3293        # and the Oklahoma Sooners Football Program.
-3294        print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.")
-3295        json_data = get_cfbd_player_advanced_game_stats(
-3296            api_key=cfbd_key,
-3297            game_id=401135278
-3298        )
-3299        print(json_data)
-3300        time.sleep(5)
-3301
-3302
-3303        # You can also tell this function to just return the API call as
-3304        # a Dictionary (read: JSON) object.
-3305        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
-3306        json_data = get_cfbd_player_advanced_game_stats(
-3307            api_key=cfbd_key,
-3308            game_id=401135278,
-3309            return_as_dict=True
+            
3258def get_cfbd_player_advanced_game_stats(
+3259        game_id: int,
+3260        api_key: str = None,
+3261        api_key_dir: str = None,
+3262        return_as_dict: bool = False):
+3263    """
+3264    Retrives advanced game stats from the CFBD API.
+3265
+3266    Parameters
+3267    ----------
+3268
+3269    `api_key` (str, optional):
+3270        Semi-optional argument. 
+3271        If `api_key` is null, this function will attempt to load a CFBD API key
+3272        from the python environment, or from a file on this computer.
+3273        If `api_key` is not null, this function will automatically assume that the
+3274        inputted `api_key` is a valid CFBD API key.
+3275
+3276    `api_key_dir` (str, optional):
+3277        Optional argument.
+3278        If `api_key` is set to am empty string, this variable is ignored.
+3279        If `api_key_dir` is null, and `api_key` is null, 
+3280        this function will try to find a CFBD API key file in this user's home directory.
+3281        If `api_key_dir` is set to a string, and `api_key` is null,
+3282        this function will assume that `api_key_dir` is a directory, 
+3283        and will try to find a CFBD API key file in that directory.
+3284    
+3285    `return_as_dict` (bool, semi-optional):
+3286        Semi-optional argument.
+3287        If you want this function to return the data as a dictionary (read: JSON object), 
+3288        instead of a pandas `DataFrame` object,
+3289        set `return_as_dict` to `True`.
+3290
+3291    Usage
+3292    ----------
+3293    ```
+3294    import time
+3295
+3296    from cfbd_json_py.games import get_cfbd_player_advanced_game_stats
+3297
+3298
+3299    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+3300
+3301    if cfbd_key != "tigersAreAwsome":
+3302        print("Using the user's API key declared in this script for this example.")
+3303
+3304        # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, 
+3305        # and the Oklahoma Sooners Football Program.
+3306        print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.")
+3307        json_data = get_cfbd_player_advanced_game_stats(
+3308            api_key=cfbd_key,
+3309            game_id=401135278
 3310        )
 3311        print(json_data)
-3312
-3313    else:
-3314        # Alternatively, if the CFBD API key exists in this python environment,
-3315        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
-3316        # you could just call these functions directly, without setting the API key
-3317        # in the script.
-3318        print("Using the user's API key suposedly loaded into this python environment for this example.")
-3319
-3320        # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, 
-3321        # and the Oklahoma Sooners Football Program.
-3322        print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.")
-3323        json_data = get_cfbd_player_advanced_game_stats(
-3324            game_id=401135278
-3325        )
-3326        print(json_data)
-3327        time.sleep(5)
-3328
-3329
-3330        # You can also tell this function to just return the API call as
-3331        # a Dictionary (read: JSON) object.
-3332        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
-3333        json_data = get_cfbd_player_advanced_game_stats(
-3334            game_id=401135278,
-3335            return_as_dict=True
-3336        )
-3337        print(json_data)
-3338
-3339    ```
-3340    Returns
-3341    ----------
-3342    A pandas `DataFrame` object with college football game information, 
-3343    or (if `return_as_dict` is set to `True`) 
-3344    a dictionary object with college football game information.
-3345    """
-3346
-3347    #now = datetime.now()
-3348    usage_df = pd.DataFrame()
-3349    ppa_df = pd.DataFrame()
-3350    adv_stats_df = pd.DataFrame()
-3351    row_df = pd.DataFrame()
-3352    url = "https://api.collegefootballdata.com/game/box/advanced"
-3353
-3354    ########################################################################################################################################################################################################
-3355
-3356    if api_key != None:
-3357        real_api_key = api_key
-3358        del api_key
-3359    else:
-3360        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
-3361
-3362    if real_api_key == "tigersAreAwsome":
-3363        raise ValueError(
-3364            "You actually need to change `cfbd_key` to your CFBD API key.")
-3365    elif "Bearer " in real_api_key:
-3366        pass
-3367    elif "Bearer" in real_api_key:
-3368        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
-3369    else:
-3370        real_api_key = "Bearer " + real_api_key
-3371
-3372    # URL builder
-3373    ########################################################################################################################################################################################################
-3374
-3375    # Required by API
-3376    url += f"?gameId={game_id}"
-3377
-3378    headers = {
-3379        'Authorization': f'{real_api_key}',
-3380        'accept': 'application/json'
-3381    }
-3382
-3383    response = requests.get(url, headers=headers)
-3384    
-3385
-3386    if response.status_code == 200:
-3387        pass
-3388    elif response.status_code == 401:
-3389        raise ConnectionRefusedError(
-3390            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
-3391        )
-3392    else:
-3393        raise ConnectionError(
-3394            f'Could not connect.\nHTTP Status code {response.status_code}'
-3395        )
-3396
-3397    json_data = response.json()
-3398
-3399    if return_as_dict == True:
-3400        return json_data
-3401
-3402    home_team_name = json_data['gameInfo']['homeTeam']
-3403    home_points = json_data['gameInfo']['homePoints']
-3404    home_win_prob = json_data['gameInfo']['homeWinProb']
-3405    away_team_name = json_data['gameInfo']['awayTeam']
-3406    away_points = json_data['gameInfo']['awayPoints']
-3407    away_win_prob = json_data['gameInfo']['awayWinProb']
-3408    home_winner = json_data['gameInfo']['homeWinner']
-3409    game_excitement_score = json_data['gameInfo']['excitement']
-3410    
-3411    
-3412    # Parsing Usage
-3413    print("Parsing player usage data.")
-3414    for player in tqdm(json_data['players']['usage']):
-3415        row_df = pd.DataFrame(
-3416            {
-3417                "game_id":game_id
-3418            },
-3419            index=[0]
-3420        )
-3421        row_df['player_name'] = player['player']
-3422        row_df['team'] = player['team']
-3423        row_df['position'] = player['position']
-3424
-3425        row_df['total_usage'] = player['total']
-3426        row_df['q1_usage'] = player['quarter1']
-3427        row_df['q2_usage'] = player['quarter2']
-3428        row_df['q3_usage'] = player['quarter3']
-3429        row_df['q4_usage'] = player['quarter4']
-3430        row_df['rushing_usage'] = player['rushing']
-3431        row_df['passing_usage'] = player['passing']
-3432
-3433        usage_df = pd.concat([usage_df,row_df],ignore_index=True)
-3434        del row_df
-3435
-3436    # Parsing PPA
-3437    print("Parsing player PPA data.")
-3438    for player in tqdm(json_data['players']['ppa']):
-3439        row_df = pd.DataFrame(
-3440            {
-3441                "game_id":game_id
-3442            },
-3443            index=[0]
-3444        )
-3445        row_df['player_name'] = player['player']
-3446        row_df['team'] = player['team']
-3447        row_df['position'] = player['position']
-3448        
-3449        row_df['average_ppa_total'] = player['average']['total']
-3450        row_df['average_ppa_q1'] = player['average']['quarter1']
-3451        row_df['average_ppa_q2'] = player['average']['quarter2']
-3452        row_df['average_ppa_q3'] = player['average']['quarter3']
-3453        row_df['average_ppa_q4'] = player['average']['quarter4']
-3454        row_df['average_ppa_rushing'] = player['average']['rushing']
-3455        row_df['average_ppa_passing'] = player['average']['passing']
-3456        
-3457        row_df['cumulative_ppa_total'] = player['cumulative']['total']
-3458        row_df['cumulative_ppa_q1'] = player['cumulative']['quarter1']
-3459        row_df['cumulative_ppa_q2'] = player['cumulative']['quarter2']
-3460        row_df['cumulative_ppa_q3'] = player['cumulative']['quarter3']
-3461        row_df['cumulative_ppa_q4'] = player['cumulative']['quarter4']
-3462        row_df['cumulative_ppa_rushing'] = player['cumulative']['rushing']
-3463        row_df['cumulative_ppa_passing'] = player['cumulative']['passing']
-3464        
-3465        ppa_df = pd.concat([ppa_df,row_df],ignore_index=True)
-3466
-3467    # Join `usage_df` and `ppa_df` together
-3468    adv_stats_df = pd.merge(
-3469        left=usage_df,
-3470        right=ppa_df,
-3471        how="outer",
-3472        on=["game_id","player_name","team","position"]
-3473    )
-3474
-3475    # Add in these columns for completeness.
-3476
-3477    adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"home_away"] = "home"
-3478    adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"opponent"] = away_team_name
-3479    
-3480    adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"home_away"] = "away"
-3481    adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"opponent"] = home_team_name
-3482    
-3483    adv_stats_df['home_team'] = home_team_name
-3484    adv_stats_df['away_team'] = away_team_name
-3485
-3486    adv_stats_df['home_win_prob'] = home_win_prob
-3487    adv_stats_df['away_win_prob'] = away_win_prob
+3312        time.sleep(5)
+3313
+3314
+3315        # You can also tell this function to just return the API call as
+3316        # a Dictionary (read: JSON) object.
+3317        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+3318        json_data = get_cfbd_player_advanced_game_stats(
+3319            api_key=cfbd_key,
+3320            game_id=401135278,
+3321            return_as_dict=True
+3322        )
+3323        print(json_data)
+3324
+3325    else:
+3326        # Alternatively, if the CFBD API key exists in this python environment,
+3327        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+3328        # you could just call these functions directly, without setting the API key
+3329        # in the script.
+3330        print("Using the user's API key suposedly loaded into this python environment for this example.")
+3331
+3332        # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, 
+3333        # and the Oklahoma Sooners Football Program.
+3334        print("Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.")
+3335        json_data = get_cfbd_player_advanced_game_stats(
+3336            game_id=401135278
+3337        )
+3338        print(json_data)
+3339        time.sleep(5)
+3340
+3341
+3342        # You can also tell this function to just return the API call as
+3343        # a Dictionary (read: JSON) object.
+3344        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+3345        json_data = get_cfbd_player_advanced_game_stats(
+3346            game_id=401135278,
+3347            return_as_dict=True
+3348        )
+3349        print(json_data)
+3350
+3351    ```
+3352    Returns
+3353    ----------
+3354    A pandas `DataFrame` object with college football game information, 
+3355    or (if `return_as_dict` is set to `True`) 
+3356    a dictionary object with college football game information.
+3357    """
+3358
+3359    #now = datetime.now()
+3360    usage_df = pd.DataFrame()
+3361    ppa_df = pd.DataFrame()
+3362    adv_stats_df = pd.DataFrame()
+3363    row_df = pd.DataFrame()
+3364    url = "https://api.collegefootballdata.com/game/box/advanced"
+3365
+3366    ########################################################################################################################################################################################################
+3367
+3368    if api_key != None:
+3369        real_api_key = api_key
+3370        del api_key
+3371    else:
+3372        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+3373
+3374    if real_api_key == "tigersAreAwsome":
+3375        raise ValueError(
+3376            "You actually need to change `cfbd_key` to your CFBD API key.")
+3377    elif "Bearer " in real_api_key:
+3378        pass
+3379    elif "Bearer" in real_api_key:
+3380        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+3381    else:
+3382        real_api_key = "Bearer " + real_api_key
+3383
+3384    # URL builder
+3385    ########################################################################################################################################################################################################
+3386
+3387    # Required by API
+3388    url += f"?gameId={game_id}"
+3389
+3390    headers = {
+3391        'Authorization': f'{real_api_key}',
+3392        'accept': 'application/json'
+3393    }
+3394
+3395    response = requests.get(url, headers=headers)
+3396    
+3397
+3398    if response.status_code == 200:
+3399        pass
+3400    elif response.status_code == 401:
+3401        raise ConnectionRefusedError(
+3402            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+3403        )
+3404    else:
+3405        raise ConnectionError(
+3406            f'Could not connect.\nHTTP Status code {response.status_code}'
+3407        )
+3408
+3409    json_data = response.json()
+3410
+3411    if return_as_dict == True:
+3412        return json_data
+3413
+3414    home_team_name = json_data['gameInfo']['homeTeam']
+3415    home_points = json_data['gameInfo']['homePoints']
+3416    home_win_prob = json_data['gameInfo']['homeWinProb']
+3417    away_team_name = json_data['gameInfo']['awayTeam']
+3418    away_points = json_data['gameInfo']['awayPoints']
+3419    away_win_prob = json_data['gameInfo']['awayWinProb']
+3420    home_winner = json_data['gameInfo']['homeWinner']
+3421    game_excitement_score = json_data['gameInfo']['excitement']
+3422    
+3423    
+3424    # Parsing Usage
+3425    print("Parsing player usage data.")
+3426    for player in tqdm(json_data['players']['usage']):
+3427        row_df = pd.DataFrame(
+3428            {
+3429                "game_id":game_id
+3430            },
+3431            index=[0]
+3432        )
+3433        row_df['player_name'] = player['player']
+3434        row_df['team'] = player['team']
+3435        row_df['position'] = player['position']
+3436
+3437        row_df['total_usage'] = player['total']
+3438        row_df['q1_usage'] = player['quarter1']
+3439        row_df['q2_usage'] = player['quarter2']
+3440        row_df['q3_usage'] = player['quarter3']
+3441        row_df['q4_usage'] = player['quarter4']
+3442        row_df['rushing_usage'] = player['rushing']
+3443        row_df['passing_usage'] = player['passing']
+3444
+3445        usage_df = pd.concat([usage_df,row_df],ignore_index=True)
+3446        del row_df
+3447
+3448    # Parsing PPA
+3449    print("Parsing player PPA data.")
+3450    for player in tqdm(json_data['players']['ppa']):
+3451        row_df = pd.DataFrame(
+3452            {
+3453                "game_id":game_id
+3454            },
+3455            index=[0]
+3456        )
+3457        row_df['player_name'] = player['player']
+3458        row_df['team'] = player['team']
+3459        row_df['position'] = player['position']
+3460        
+3461        row_df['average_ppa_total'] = player['average']['total']
+3462        row_df['average_ppa_q1'] = player['average']['quarter1']
+3463        row_df['average_ppa_q2'] = player['average']['quarter2']
+3464        row_df['average_ppa_q3'] = player['average']['quarter3']
+3465        row_df['average_ppa_q4'] = player['average']['quarter4']
+3466        row_df['average_ppa_rushing'] = player['average']['rushing']
+3467        row_df['average_ppa_passing'] = player['average']['passing']
+3468        
+3469        row_df['cumulative_ppa_total'] = player['cumulative']['total']
+3470        row_df['cumulative_ppa_q1'] = player['cumulative']['quarter1']
+3471        row_df['cumulative_ppa_q2'] = player['cumulative']['quarter2']
+3472        row_df['cumulative_ppa_q3'] = player['cumulative']['quarter3']
+3473        row_df['cumulative_ppa_q4'] = player['cumulative']['quarter4']
+3474        row_df['cumulative_ppa_rushing'] = player['cumulative']['rushing']
+3475        row_df['cumulative_ppa_passing'] = player['cumulative']['passing']
+3476        
+3477        ppa_df = pd.concat([ppa_df,row_df],ignore_index=True)
+3478
+3479    # Join `usage_df` and `ppa_df` together
+3480    adv_stats_df = pd.merge(
+3481        left=usage_df,
+3482        right=ppa_df,
+3483        how="outer",
+3484        on=["game_id","player_name","team","position"]
+3485    )
+3486
+3487    # Add in these columns for completeness.
 3488
-3489    adv_stats_df['home_points'] = home_points
-3490    adv_stats_df['away_points'] = away_points
-3491
-3492    adv_stats_df['home_winner'] = home_winner
-3493    adv_stats_df['game_excitement_score'] = game_excitement_score
-3494
-3495    return adv_stats_df
+3489    adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"home_away"] = "home"
+3490    adv_stats_df.loc[adv_stats_df["team"]==home_team_name,"opponent"] = away_team_name
+3491    
+3492    adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"home_away"] = "away"
+3493    adv_stats_df.loc[adv_stats_df["team"]==away_team_name,"opponent"] = home_team_name
+3494    
+3495    adv_stats_df['home_team'] = home_team_name
+3496    adv_stats_df['away_team'] = away_team_name
+3497
+3498    adv_stats_df['home_win_prob'] = home_win_prob
+3499    adv_stats_df['away_win_prob'] = away_win_prob
+3500
+3501    adv_stats_df['home_points'] = home_points
+3502    adv_stats_df['away_points'] = away_points
+3503
+3504    adv_stats_df['home_winner'] = home_winner
+3505    adv_stats_df['game_excitement_score'] = game_excitement_score
+3506
+3507    return adv_stats_df
 
@@ -8387,21 +8411,21 @@

Returns

-
3505def get_cfbd_live_scoreboard(
-3506        api_key: str = None,
-3507        api_key_dir: str = None,
-3508        ncaa_division: str = "fbs",
-3509        conference: str = None):
-3510    """
-3511    YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!
-3512    To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata
-3513
-3514
-3515    """
-3516
-3517    raise NotImplementedError(
-3518        'This function has yet to be implemented by this version.'
-3519    )
+            
3517def get_cfbd_live_scoreboard(
+3518        api_key: str = None,
+3519        api_key_dir: str = None,
+3520        ncaa_division: str = "fbs",
+3521        conference: str = None):
+3522    """
+3523    YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!
+3524    To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata
+3525
+3526
+3527    """
+3528
+3529    raise NotImplementedError(
+3530        'This function has yet to be implemented by this version.'
+3531    )
 
@@ -8422,24 +8446,24 @@

Returns

-
3522def get_cfbd_weather_info(
-3523        api_key: str = None,
-3524        api_key_dir: str = None,
-3525        ncaa_division: str = "fbs",
-3526        game_id: int = None,
-3527        # `game_id` and/or `year` must be not null for this function to work.
-3528        season: int = None,
-3529        week: int = None,
-3530        season_type: str = "regular",  # "regular", "postseason", or "both"
-3531        conference: str = None):
-3532    """
-3533    YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!
-3534    To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata
-3535    """
-3536
-3537    raise NotImplementedError(
-3538        'This function has yet to be implemented by this version.'
-3539    )
+            
3534def get_cfbd_weather_info(
+3535        api_key: str = None,
+3536        api_key_dir: str = None,
+3537        ncaa_division: str = "fbs",
+3538        game_id: int = None,
+3539        # `game_id` and/or `year` must be not null for this function to work.
+3540        season: int = None,
+3541        week: int = None,
+3542        season_type: str = "regular",  # "regular", "postseason", or "both"
+3543        conference: str = None):
+3544    """
+3545    YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!
+3546    To view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata
+3547    """
+3548
+3549    raise NotImplementedError(
+3550        'This function has yet to be implemented by this version.'
+3551    )
 
diff --git a/docs/cfbd_json_py/metrics.html b/docs/cfbd_json_py/metrics.html index e9096a0..0fa58b0 100644 --- a/docs/cfbd_json_py/metrics.html +++ b/docs/cfbd_json_py/metrics.html @@ -73,7 +73,7 @@

   1# Creation Date: 08/30/2023 01:13 EDT
-   2# Last Updated Date: 10/23/2023 11:09 PM EDT
+   2# Last Updated Date: 11/04/2023 02:55 PM EDT
    3# Author: Joseph Armstrong (armstrongjoseph08@gmail.com)
    4# File Name: metrics.py
    5# Purpose: Houses functions pertaining to various CFB stats within the CFBD API.
@@ -564,7 +564,7 @@ 

490 # Rare, but in this endpoint, 491 # you don't need to input the season. 492 pass - 493 elif season > now.year: + 493 elif season > (now.year + 1): 494 raise ValueError(f"`season` cannot be greater than {season}.") 495 elif season < 1869: 496 raise ValueError(f"`season` cannot be less than 1869.") @@ -957,7 +957,7 @@

883 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 884 "https://github.com/armstjc/cfbd-json-py/issues" 885 ) - 886 elif season > now.year: + 886 elif season > (now.year + 1): 887 raise ValueError(f"`season` cannot be greater than {season}.") 888 elif season < 1869: 889 raise ValueError(f"`season` cannot be less than 1869.") @@ -1380,7 +1380,7 @@

1306 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 1307 "https://github.com/armstjc/cfbd-json-py/issues" 1308 ) -1309 elif season > now.year: +1309 elif season > (now.year + 1): 1310 raise ValueError(f"`season` cannot be greater than {season}.") 1311 elif season < 1869: 1312 raise ValueError(f"`season` cannot be less than 1869.") @@ -1842,7 +1842,7 @@

1768 1769 if season == None: 1770 pass -1771 elif season > now.year: +1771 elif season > (now.year + 1): 1772 raise ValueError(f"`season` cannot be greater than {season}.") 1773 elif season < 1869: 1774 raise ValueError(f"`season` cannot be less than 1869.") @@ -2424,7 +2424,7 @@

2350 2351 if season == None: 2352 pass -2353 elif season > now.year: +2353 elif season > (now.year + 1): 2354 raise ValueError(f"`season` cannot be greater than {season}.") 2355 elif season < 1869: 2356 raise ValueError(f"`season` cannot be less than 1869.") @@ -3151,7 +3151,7 @@

Returns

491 # Rare, but in this endpoint, 492 # you don't need to input the season. 493 pass -494 elif season > now.year: +494 elif season > (now.year + 1): 495 raise ValueError(f"`season` cannot be greater than {season}.") 496 elif season < 1869: 497 raise ValueError(f"`season` cannot be less than 1869.") @@ -3748,7 +3748,7 @@

Returns

884 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 885 "https://github.com/armstjc/cfbd-json-py/issues" 886 ) -887 elif season > now.year: +887 elif season > (now.year + 1): 888 raise ValueError(f"`season` cannot be greater than {season}.") 889 elif season < 1869: 890 raise ValueError(f"`season` cannot be less than 1869.") @@ -4424,7 +4424,7 @@

Returns

1307 "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" + 1308 "https://github.com/armstjc/cfbd-json-py/issues" 1309 ) -1310 elif season > now.year: +1310 elif season > (now.year + 1): 1311 raise ValueError(f"`season` cannot be greater than {season}.") 1312 elif season < 1869: 1313 raise ValueError(f"`season` cannot be less than 1869.") @@ -5165,7 +5165,7 @@

Returns

1769 1770 if season == None: 1771 pass -1772 elif season > now.year: +1772 elif season > (now.year + 1): 1773 raise ValueError(f"`season` cannot be greater than {season}.") 1774 elif season < 1869: 1775 raise ValueError(f"`season` cannot be less than 1869.") @@ -6160,7 +6160,7 @@

Returns

2351 2352 if season == None: 2353 pass -2354 elif season > now.year: +2354 elif season > (now.year + 1): 2355 raise ValueError(f"`season` cannot be greater than {season}.") 2356 elif season < 1869: 2357 raise ValueError(f"`season` cannot be less than 1869.") diff --git a/docs/cfbd_json_py/players.html b/docs/cfbd_json_py/players.html index 4dcb9f4..7e23d92 100644 --- a/docs/cfbd_json_py/players.html +++ b/docs/cfbd_json_py/players.html @@ -66,96 +66,2544 @@

-
 1# Creation Date: 08/30/2023 01:13 EDT
- 2# Last Updated Date: 10/06/2023 07:53 PM EDT
- 3# Author: Joseph Armstrong (armstrongjoseph08@gmail.com)
- 4# File Name: players.py
- 5# Purpose: Houses functions pertaining to CFB player data within the CFBD API.
- 6####################################################################################################
- 7
- 8
- 9def cfbd_player_search(
-10        search_str: str,
-11        api_key: str = None,
-12        api_key_dir: str = None,
-13        position: str = None,
-14        team: str = None,
-15        season: int = None,
-16        return_as_dict: bool = False):
-17    """
-18
-19    """
-20    raise NotImplementedError(
-21        'This function has yet to be implemented by this version.'
-22    )
-23
-24
-25def get_cfbd_player_usage(
-26        season: int,
-27        api_key: str = None,
-28        api_key_dir: str = None,
-29        team: str = None,
-30        conference_abv: str = None,
-31        position: str = None,
-32        player_id: int = None,
-33        exclude_garbage_time: bool = False,
-34        return_as_dict: bool = False):
-35    """
-36
-37    """
-38    raise NotImplementedError(
-39        'This function has yet to be implemented by this version.'
-40    )
-41
-42
-43def get_cfbd_returning_production(
-44        season: int,
-45        api_key: str = None,
-46        api_key_dir: str = None,
-47        team: str = None,
-48        conference_abv: str = None,
-49
-50        return_as_dict: bool = False):
-51    """
-52
-53    """
-54    raise NotImplementedError(
-55        'This function has yet to be implemented by this version.'
-56    )
-57
-58
-59def get_cfbd_player_season_stats(
-60        season: int,
-61        api_key: str = None,
-62        api_key_dir: str = None,
-63        team: str = None,
-64        conference_abv: str = None,
-65        start_week: int = None,
-66        end_week: int = None,
-67        season_type: str = 'regular',  # "regular", "postseason", or "both"
-68        stat_category: str = None,
-69
-70        return_as_dict: bool = False):
-71    """
-72
-73    """
-74    raise NotImplementedError(
-75        'This function has yet to be implemented by this version.'
-76    )
-77
-78
-79def get_cfbd_transfer_portal_data(
-80        season: int,
-81        api_key: str = None,
-82        api_key_dir: str = None,
-83
-84        return_as_dict: bool = False):
-85    """
-86
-87    """
-88    raise NotImplementedError(
-89        'This function has yet to be implemented by this version.'
-90    )
+                        
   1# Creation Date: 08/30/2023 01:13 EDT
+   2# Last Updated Date: 11/04/2023 03:09 PM EDT
+   3# Author: Joseph Armstrong (armstrongjoseph08@gmail.com)
+   4# File Name: players.py
+   5# Purpose: Houses functions pertaining to CFB player data within the CFBD API.
+   6####################################################################################################
+   7
+   8
+   9from datetime import datetime
+  10import logging
+  11
+  12import pandas as pd
+  13import requests
+  14from tqdm import tqdm
+  15
+  16from cfbd_json_py.games import get_cfbd_player_game_stats
+  17from cfbd_json_py.utls import get_cfbd_api_token
+  18
+  19
+  20def cfbd_player_search(
+  21        search_str: str,
+  22        api_key: str = None,
+  23        api_key_dir: str = None,
+  24        position: str = None,
+  25        team: str = None,
+  26        season: int = None,
+  27        return_as_dict: bool = False):
+  28    """
+  29    Given a string, search for players who's 
+  30    name matches that string in some capacity.
+  31
+  32    Parameters
+  33    ----------
+  34    `search_str` (int, mandatory):
+  35        Mandatory argument.
+  36        This is the name of the player you are trying to find.
+  37
+  38    `api_key` (str, optional):
+  39        Semi-optional argument. 
+  40        If `api_key` is null, this function will attempt to load a CFBD API key
+  41        from the python environment, or from a file on this computer.
+  42        If `api_key` is not null, this function will automatically assume that the
+  43        inputted `api_key` is a valid CFBD API key.
+  44
+  45    `api_key_dir` (str, optional):
+  46        Optional argument.
+  47        If `api_key` is set to am empty string, this variable is ignored.
+  48        If `api_key_dir` is null, and `api_key` is null, 
+  49        this function will try to find a CFBD API key file in this user's home directory.
+  50        If `api_key_dir` is set to a string, and `api_key` is null,
+  51        this function will assume that `api_key_dir` is a directory, 
+  52        and will try to find a CFBD API key file in that directory.
+  53
+  54    `position` (bool, semi-optional):
+  55        Semi-optional argument.
+  56        If you only want players from a specific position, 
+  57        set `position` to the position you want to find players from.
+  58
+  59    `team` (bool, semi-optional):
+  60        Semi-optional argument.
+  61        If you only want players from a specific team, 
+  62        set `team` to the name of the team you want to find players from.
+  63
+  64    `season` (bool, semi-optional):
+  65        Semi-optional argument.
+  66        If you only want players from a specific CFB season, 
+  67        set `season` to the season you want to find players from.
+  68
+  69    `return_as_dict` (bool, semi-optional):
+  70        Semi-optional argument.
+  71        If you want this function to return the data as a dictionary (read: JSON object), 
+  72        instead of a pandas `DataFrame` object,
+  73        set `return_as_dict` to `True`.
+  74
+  75    Usage
+  76    ----------
+  77    ```
+  78    import time
+  79
+  80    from cfbd_json_py.players import cfbd_player_search
+  81
+  82
+  83    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+  84
+  85    if cfbd_key != "tigersAreAwsome":
+  86        print("Using the user's API key declared in this script for this example.")
+  87
+  88        # Get a list of every known "Joe" in the CFBD API.
+  89        print("Get a list of every known \"Joe\" in the CFBD API.")
+  90        json_data = cfbd_player_search(
+  91            api_key=cfbd_key,
+  92            search_str="Joe"
+  93        )
+  94        print(json_data)
+  95        time.sleep(5)
+  96
+  97        # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".
+  98        print("Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".")
+  99        json_data = cfbd_player_search(
+ 100            api_key=cfbd_key,
+ 101            search_str="Joe B"
+ 102        )
+ 103        print(json_data)
+ 104        time.sleep(5)
+ 105
+ 106        # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.
+ 107        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.")
+ 108        json_data = cfbd_player_search(
+ 109            api_key=cfbd_key,
+ 110            search_str="Jim",
+ 111            position="QB"
+ 112        )
+ 113        print(json_data)
+ 114        time.sleep(5)
+ 115
+ 116
+ 117        # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.
+ 118        print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.")
+ 119        json_data = cfbd_player_search(
+ 120            api_key=cfbd_key,
+ 121            search_str="A",
+ 122            team="Cincinnati"
+ 123        )
+ 124        print(json_data)
+ 125        time.sleep(5)
+ 126
+ 127
+ 128        # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.
+ 129        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.")
+ 130        json_data = cfbd_player_search(
+ 131            api_key=cfbd_key,
+ 132            search_str="Jim",
+ 133            position="QB"
+ 134        )
+ 135        print(json_data)
+ 136        time.sleep(5)
+ 137
+ 138        # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.
+ 139        print("Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.")
+ 140        json_data = cfbd_player_search(
+ 141            api_key=cfbd_key,
+ 142            search_str="Joe",
+ 143            season=2020
+ 144        )
+ 145        print(json_data)
+ 146        time.sleep(5)
+ 147
+ 148
+ 149        # You can also tell this function to just return the API call as
+ 150        # a Dictionary (read: JSON) object.
+ 151        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 152        json_data = cfbd_player_search(
+ 153            api_key=cfbd_key,
+ 154            search_str="Justin F",
+ 155            season=2020,
+ 156            return_as_dict=True
+ 157        )
+ 158        print(json_data)
+ 159
+ 160    else:
+ 161        # Alternatively, if the CFBD API key exists in this python environment,
+ 162        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+ 163        # you could just call these functions directly, without setting the API key
+ 164        # in the script.
+ 165        print("Using the user's API key suposedly loaded into this python environment for this example.")
+ 166
+ 167        # Get a list of every known "Joe" in the CFBD API.
+ 168        print("Get a list of every known \"Joe\" in the CFBD API.")
+ 169        json_data = cfbd_player_search(
+ 170            search_str="Joe"
+ 171        )
+ 172        print(json_data)
+ 173        time.sleep(5)
+ 174
+ 175        # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".
+ 176        print("Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".")
+ 177        json_data = cfbd_player_search(
+ 178            search_str="Joe B"
+ 179        )
+ 180        print(json_data)
+ 181        time.sleep(5)
+ 182
+ 183        # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.
+ 184        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.")
+ 185        json_data = cfbd_player_search(
+ 186            search_str="Jim",
+ 187            position="QB"
+ 188        )
+ 189        print(json_data)
+ 190        time.sleep(5)
+ 191
+ 192
+ 193        # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.
+ 194        print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.")
+ 195        json_data = cfbd_player_search(
+ 196            search_str="A",
+ 197            team="Cincinnati"
+ 198        )
+ 199        print(json_data)
+ 200        time.sleep(5)
+ 201
+ 202
+ 203        # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.
+ 204        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.")
+ 205        json_data = cfbd_player_search(
+ 206            search_str="Jim",
+ 207            position="QB"
+ 208        )
+ 209        print(json_data)
+ 210        time.sleep(5)
+ 211
+ 212        # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.
+ 213        print("Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.")
+ 214        json_data = cfbd_player_search(
+ 215            search_str="Joe",
+ 216            season=2020
+ 217        )
+ 218        print(json_data)
+ 219        time.sleep(5)
+ 220
+ 221
+ 222        # You can also tell this function to just return the API call as
+ 223        # a Dictionary (read: JSON) object.
+ 224        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 225        json_data = cfbd_player_search(
+ 226            search_str="Justin F",
+ 227            season=2020,
+ 228            return_as_dict=True
+ 229        )
+ 230        print(json_data)
+ 231
+ 232    ```
+ 233    Returns
+ 234    ----------
+ 235    A pandas `DataFrame` object with a list of players who matched the search string, 
+ 236    or (if `return_as_dict` is set to `True`) 
+ 237    a dictionary object with a list of players who matched the search string.
+ 238
+ 239    """
+ 240    now = datetime.now()
+ 241    players_df = pd.DataFrame()
+ 242    row_df = pd.DataFrame()
+ 243    url = "https://api.collegefootballdata.com/player/search"
+ 244
+ 245    ########################################################################################################################################################################################################
+ 246
+ 247    if api_key != None:
+ 248        real_api_key = api_key
+ 249        del api_key
+ 250    else:
+ 251        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+ 252
+ 253    if real_api_key == "tigersAreAwsome":
+ 254        raise ValueError(
+ 255            "You actually need to change `cfbd_key` to your CFBD API key.")
+ 256    elif "Bearer " in real_api_key:
+ 257        pass
+ 258    elif "Bearer" in real_api_key:
+ 259        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+ 260    else:
+ 261        real_api_key = "Bearer " + real_api_key
+ 262
+ 263    if season == None:
+ 264        # Rare, but in this endpoint,
+ 265        # you don't need to input the season.
+ 266        pass
+ 267    elif season > (now.year + 1):
+ 268        raise ValueError(f"`season` cannot be greater than {season}.")
+ 269    elif season < 1869:
+ 270        raise ValueError(f"`season` cannot be less than 1869.")
+ 271
+ 272    # URL builder
+ 273    ########################################################################################################################################################################################################
+ 274
+ 275    # Required by API
+ 276    url += f"?searchTerm={search_str}"
+ 277
+ 278    url = url.replace(" ", "%20")  # For sanity reasons with URLs.
+ 279
+ 280    if position != None:
+ 281        url += f"&position={position}"
+ 282
+ 283    if team != None:
+ 284        url += f"&team={team}"
+ 285
+ 286    if season != None:
+ 287        url += f"&year={season}"
+ 288
+ 289    headers = {
+ 290        'Authorization': f'{real_api_key}',
+ 291        'accept': 'application/json'
+ 292    }
+ 293
+ 294    response = requests.get(url, headers=headers)
+ 295
+ 296    if response.status_code == 200:
+ 297        pass
+ 298    elif response.status_code == 401:
+ 299        raise ConnectionRefusedError(
+ 300            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+ 301        )
+ 302    else:
+ 303        raise ConnectionError(
+ 304            f'Could not connect.\nHTTP Status code {response.status_code}'
+ 305        )
+ 306
+ 307    json_data = response.json()
+ 308
+ 309    if return_as_dict == True:
+ 310        return json_data
+ 311
+ 312    for player in tqdm(json_data):
+ 313        p_id = player['id']
+ 314        row_df = pd.DataFrame(
+ 315            {"player_id": p_id},
+ 316            index=[0]
+ 317        )
+ 318        row_df['team'] = player['team']
+ 319        row_df['player_full_name'] = player['name']
+ 320        row_df['player_first_name'] = player['firstName']
+ 321        row_df['player_last_name'] = player['lastName']
+ 322        row_df['weight_lbs'] = player['weight']
+ 323        row_df['height_in'] = player['height']
+ 324        row_df['jersey'] = player['jersey']
+ 325        row_df['position'] = player['position']
+ 326        row_df['hometown'] = player['hometown']
+ 327        row_df['team_color_primary'] = player['teamColor']
+ 328        row_df['team_color_secondary'] = player['teamColorSecondary']
+ 329
+ 330        players_df = pd.concat([players_df, row_df], ignore_index=True)
+ 331
+ 332        del row_df
+ 333        del p_id
+ 334
+ 335    return players_df
+ 336
+ 337
+ 338def get_cfbd_player_usage(
+ 339        season: int,
+ 340        api_key: str = None,
+ 341        api_key_dir: str = None,
+ 342        team: str = None,
+ 343        conference_abv: str = None,
+ 344        position: str = None,
+ 345        player_id: int = None,
+ 346        exclude_garbage_time: bool = False,
+ 347        return_as_dict: bool = False):
+ 348    """
+ 349    Get player usage data (A.K.A., the percentages for how often a player touched the ball),
+ 350    for a given season, at the season level, from the CFBD API.
+ 351
+ 352    Parameters
+ 353    ----------
+ 354    `season` (int, optional):
+ 355        Mandatory argument.
+ 356        Specifies the season you want player usage data from.
+ 357        You MUST set `season` or `team` to a non-null value for 
+ 358        this function to work. If you don't, a `ValueError()` 
+ 359        will be raised.
+ 360
+ 361    `api_key` (str, optional):
+ 362        Semi-optional argument. 
+ 363        If `api_key` is null, this function will attempt to load a CFBD API key
+ 364        from the python environment, or from a file on this computer.
+ 365        If `api_key` is not null, this function will automatically assume that the
+ 366        inputted `api_key` is a valid CFBD API key.
+ 367
+ 368    `api_key_dir` (str, optional):
+ 369        Optional argument.
+ 370        If `api_key` is set to am empty string, this variable is ignored.
+ 371        If `api_key_dir` is null, and `api_key` is null, 
+ 372        this function will try to find a CFBD API key file in this user's home directory.
+ 373        If `api_key_dir` is set to a string, and `api_key` is null,
+ 374        this function will assume that `api_key_dir` is a directory, 
+ 375        and will try to find a CFBD API key file in that directory.
+ 376
+ 377    `team` (str, optional):
+ 378        Semi-ptional argument.
+ 379        If you only want player usage data for a specific team,
+ 380        set `team` to the name of the team you want player usage data from.
+ 381        You MUST set `season` or `team` to a non-null value for 
+ 382        this function to work. If you don't, a `ValueError()` 
+ 383        will be raised.
+ 384
+ 385    `position` (str, optional):
+ 386        Semi-Optional argument.
+ 387        If you only want player usage data 
+ 388        for players who played a specific position, 
+ 389        set `position` to that position's abbreviation. 
+ 390        A list of CFBD API positions can be found in the `position_abbreviation` column from 
+ 391        the pandas DataFrame that is returned by calling `cfbd_json_py.draft.get_cfbd_nfl_positions()`.
+ 392
+ 393    `conference_abv` (str, optional):
+ 394        Optional argument.
+ 395        If you only want player usage data from games 
+ 396        involving teams from a specific confrence, 
+ 397        set `conference_abv` to the abbreviation 
+ 398        of the conference you want player usage data from.
+ 399        For a list of confrences, 
+ 400        use the `cfbd_json_py.conferences.get_cfbd_conference_info()`
+ 401        function.
+ 402
+ 403    `player_id` (int, optional):
+ 404        Optional argument.
+ 405        If you only want player usage data for a specific player ID, 
+ 406        set this variable to the player ID of the player you want player usage data from. 
+ 407
+ 408    `exclude_garbage_time` (bool, optional):
+ 409        Optional argument.
+ 410        If you want to filter out plays where the result of the game is largely decided,
+ 411        set `exclude_garbage_time = True`.
+ 412        Default behavior is that this variable is set to 
+ 413        `False` when this function is called.
+ 414
+ 415    `return_as_dict` (bool, semi-optional):
+ 416        Semi-optional argument.
+ 417        If you want this function to return the data as a dictionary (read: JSON object), 
+ 418        instead of a pandas `DataFrame` object,
+ 419        set `return_as_dict` to `True`.
+ 420
+ 421    Usage
+ 422    ----------
+ 423    ```
+ 424    import time
+ 425
+ 426    from cfbd_json_py.players import get_cfbd_player_usage
+ 427
+ 428
+ 429    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+ 430
+ 431    if cfbd_key != "tigersAreAwsome":
+ 432        print("Using the user's API key declared in this script for this example.")
+ 433
+ 434        # Get player usage data from the 2020 CFB season.
+ 435        print("Get player usage data from the 2020 CFB season.")
+ 436        json_data = get_cfbd_player_usage(
+ 437            api_key=cfbd_key,
+ 438            season=2020
+ 439        )
+ 440        print(json_data)
+ 441        time.sleep(5)
+ 442
+ 443        # Get player usage data for the 
+ 444        # University of Cincinnati Bearcats Football Team, 
+ 445        # during the 2020 CFB season.
+ 446        print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.")
+ 447        json_data = get_cfbd_player_usage(
+ 448            api_key=cfbd_key,
+ 449            season=2020,
+ 450            team="Cincinnati"
+ 451        )
+ 452        print(json_data)
+ 453        time.sleep(5)
+ 454
+ 455        # Get player usage data from players who 
+ 456        # primarily played running back (RB) in the 2020 CFB season.
+ 457        print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.")
+ 458        json_data = get_cfbd_player_usage(
+ 459            api_key=cfbd_key,
+ 460            season=2020,
+ 461            position="RB"
+ 462        )
+ 463        print(json_data)
+ 464        time.sleep(5)
+ 465
+ 466        # Get player usage data from players who played on 
+ 467        # Big 10 Confrence (B1G) teams during the 2020 CFB Season.
+ 468        print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.")
+ 469        json_data = get_cfbd_player_usage(
+ 470            api_key=cfbd_key,
+ 471            season=2020,
+ 472            conference_abv="B1G"
+ 473        )
+ 474        print(json_data)
+ 475        time.sleep(5)
+ 476
+ 477        # Get player usage data from 
+ 478        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+ 479        # during the 2019 CFB season.
+ 480        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+ 481        json_data = get_cfbd_player_usage(
+ 482            api_key=cfbd_key,
+ 483            season=2019,
+ 484            player_id=3915511
+ 485        )
+ 486        print(json_data)
+ 487        time.sleep(5)
+ 488
+ 489        # Get player usage data from 
+ 490        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+ 491        # during the 2019 CFB season, 
+ 492        # but filter out plays that occured in garbage time.
+ 493        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+ 494        json_data = get_cfbd_player_usage(
+ 495            api_key=cfbd_key,
+ 496            season=2019,
+ 497            player_id=3915511,
+ 498            exclude_garbage_time=True
+ 499        )
+ 500        print(json_data)
+ 501        time.sleep(5)
+ 502
+ 503        # You can also tell this function to just return the API call as
+ 504        # a Dictionary (read: JSON) object.
+ 505        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 506        json_data = get_cfbd_player_usage(
+ 507            api_key=cfbd_key,
+ 508            season=2020,
+ 509            team="LSU",
+ 510            return_as_dict=True
+ 511        )
+ 512        print(json_data)
+ 513
+ 514    else:
+ 515        # Alternatively, if the CFBD API key exists in this python environment,
+ 516        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+ 517        # you could just call these functions directly, without setting the API key
+ 518        # in the script.
+ 519        print("Using the user's API key suposedly loaded into this python environment for this example.")
+ 520
+ 521        # Get player usage data from the 2020 CFB season.
+ 522        print("Get player usage data from the 2020 CFB season.")
+ 523        json_data = get_cfbd_player_usage(
+ 524            season=2020
+ 525        )
+ 526        print(json_data)
+ 527        time.sleep(5)
+ 528
+ 529        # Get player usage data for the 
+ 530        # University of Cincinnati Bearcats Football Team, 
+ 531        # during the 2020 CFB season.
+ 532        print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.")
+ 533        json_data = get_cfbd_player_usage(
+ 534            season=2020,
+ 535            team="Cincinnati"
+ 536        )
+ 537        print(json_data)
+ 538        time.sleep(5)
+ 539
+ 540        # Get player usage data from players who 
+ 541        # primarily played running back (RB) in the 2020 CFB season.
+ 542        print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.")
+ 543        json_data = get_cfbd_player_usage(
+ 544            season=2020,
+ 545            position="RB"
+ 546        )
+ 547        print(json_data)
+ 548        time.sleep(5)
+ 549
+ 550        # Get player usage data from players who played on 
+ 551        # Big 10 Confrence (B1G) teams during the 2020 CFB Season.
+ 552        print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.")
+ 553        json_data = get_cfbd_player_usage(
+ 554            season=2020,
+ 555            conference_abv="B1G"
+ 556        )
+ 557        print(json_data)
+ 558        time.sleep(5)
+ 559
+ 560        # Get player usage data from 
+ 561        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+ 562        # during the 2019 CFB season.
+ 563        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+ 564        json_data = get_cfbd_player_usage(
+ 565            season=2019,
+ 566            player_id=3915511
+ 567        )
+ 568        print(json_data)
+ 569        time.sleep(5)
+ 570
+ 571        # Get player usage data from 
+ 572        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+ 573        # during the 2019 CFB season, 
+ 574        # but filter out plays that occured in garbage time.
+ 575        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+ 576        json_data = get_cfbd_player_usage(
+ 577            season=2019,
+ 578            player_id=3915511,
+ 579            exclude_garbage_time=True
+ 580        )
+ 581        print(json_data)
+ 582        time.sleep(5)
+ 583
+ 584        # You can also tell this function to just return the API call as
+ 585        # a Dictionary (read: JSON) object.
+ 586        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 587        json_data = get_cfbd_player_usage(
+ 588            season=2020,
+ 589            team="LSU",
+ 590            return_as_dict=True
+ 591        )
+ 592        print(json_data)
+ 593
+ 594
+ 595    ```
+ 596    Returns
+ 597    ----------
+ 598    A pandas `DataFrame` object with player usage data, 
+ 599    or (if `return_as_dict` is set to `True`) 
+ 600    a dictionary object with player usage data.
+ 601
+ 602    """
+ 603
+ 604    now = datetime.now()
+ 605    players_df = pd.DataFrame()
+ 606    row_df = pd.DataFrame()
+ 607    url = "https://api.collegefootballdata.com/player/usage"
+ 608
+ 609    ########################################################################################################################################################################################################
+ 610
+ 611    if api_key != None:
+ 612        real_api_key = api_key
+ 613        del api_key
+ 614    else:
+ 615        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+ 616
+ 617    if real_api_key == "tigersAreAwsome":
+ 618        raise ValueError(
+ 619            "You actually need to change `cfbd_key` to your CFBD API key.")
+ 620    elif "Bearer " in real_api_key:
+ 621        pass
+ 622    elif "Bearer" in real_api_key:
+ 623        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+ 624    else:
+ 625        real_api_key = "Bearer " + real_api_key
+ 626
+ 627    if season == None:
+ 628        # This should never happen without user tampering, but if it does,
+ 629        # we need to raise an error, because the CFBD API will refuse this call without a valid season.
+ 630        raise SystemError(
+ 631            "I don't know how, I don't know why, but you managed to call this function while `season` was `None` (NULL)," +
+ 632            " and the function got to this point in the code." +
+ 633            "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
+ 634            "https://github.com/armstjc/cfbd-json-py/issues"
+ 635        )
+ 636    elif season > (now.year + 1):
+ 637        raise ValueError(f"`season` cannot be greater than {season}.")
+ 638    elif season < 1869:
+ 639        raise ValueError(f"`season` cannot be less than 1869.")
+ 640
+ 641    gt_str = ""
+ 642    if exclude_garbage_time == True:
+ 643        gt_str = "true"
+ 644    elif exclude_garbage_time == False:
+ 645        gt_str = "false"
+ 646
+ 647    # URL builder
+ 648    ########################################################################################################################################################################################################
+ 649
+ 650    url += f"?year={season}"
+ 651
+ 652    if team != None:
+ 653        url += f"&team={team}"
+ 654
+ 655    if conference_abv != None:
+ 656        url += f"&conference={conference_abv}"
+ 657
+ 658    if position != None:
+ 659        url += f"&position={position}"
+ 660
+ 661    if player_id != None:
+ 662        url += f"&playerId={player_id}"
+ 663        print()
+ 664    if exclude_garbage_time != None:
+ 665        url += f"&excludeGarbageTime={gt_str}"
+ 666
+ 667    headers = {
+ 668        'Authorization': f'{real_api_key}',
+ 669        'accept': 'application/json'
+ 670    }
+ 671
+ 672    response = requests.get(url, headers=headers)
+ 673
+ 674    if response.status_code == 200:
+ 675        pass
+ 676    elif response.status_code == 401:
+ 677        raise ConnectionRefusedError(
+ 678            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+ 679        )
+ 680    else:
+ 681        raise ConnectionError(
+ 682            f'Could not connect.\nHTTP Status code {response.status_code}'
+ 683        )
+ 684
+ 685    json_data = response.json()
+ 686
+ 687    if return_as_dict == True:
+ 688        return json_data
+ 689
+ 690    for player in tqdm(json_data):
+ 691        row_df = pd.DataFrame(
+ 692            {"season": season},
+ 693            index=[0]
+ 694        )
+ 695        row_df['player_id'] = player['id']
+ 696        row_df['player_name'] = player['name']
+ 697        row_df['player_position'] = player['position']
+ 698        row_df['team'] = player['team']
+ 699        row_df['conference'] = player['conference']
+ 700        row_df['player_usage_overall'] = player['usage']['overall']
+ 701        row_df['player_usage_passing'] = player['usage']['pass']
+ 702        row_df['player_usage_rushing'] = player['usage']['rush']
+ 703        row_df['player_usage_1st_downs'] = player['usage']['firstDown']
+ 704        row_df['player_usage_2nd_downs'] = player['usage']['secondDown']
+ 705        row_df['player_usage_3rd_downs'] = player['usage']['thirdDown']
+ 706        row_df['player_usage_standard_downs'] = player['usage']['standardDowns']
+ 707        row_df['player_usage_pasing_downs'] = player['usage']['passingDowns']
+ 708
+ 709        players_df = pd.concat([players_df, row_df], ignore_index=True)
+ 710        del row_df
+ 711
+ 712    return players_df
+ 713
+ 714
+ 715def get_cfbd_returning_production(
+ 716        api_key: str = None,
+ 717        api_key_dir: str = None,
+ 718        season: int = None,
+ 719        team: str = None,
+ 720        # `season` or `team` must be specified.
+ 721        conference_abv: str = None,
+ 722        return_as_dict: bool = False):
+ 723    """
+ 724    Get data from the CFBD API 
+ 725    on how much returning production a team has going into a CFB season.
+ 726
+ 727    Parameters
+ 728    ----------
+ 729
+ 730    `api_key` (str, optional):
+ 731        Semi-optional argument. 
+ 732        If `api_key` is null, this function will attempt to load a CFBD API key
+ 733        from the python environment, or from a file on this computer.
+ 734        If `api_key` is not null, this function will automatically assume that the
+ 735        inputted `api_key` is a valid CFBD API key.
+ 736
+ 737    `api_key_dir` (str, optional):
+ 738        Optional argument.
+ 739        If `api_key` is set to am empty string, this variable is ignored.
+ 740        If `api_key_dir` is null, and `api_key` is null, 
+ 741        this function will try to find a CFBD API key file in this user's home directory.
+ 742        If `api_key_dir` is set to a string, and `api_key` is null,
+ 743        this function will assume that `api_key_dir` is a directory, 
+ 744        and will try to find a CFBD API key file in that directory.
+ 745
+ 746    `season` (int, optional):
+ 747        Semi-optional argument. 
+ 748        Specifies the season you want team PPA data from.
+ 749        You MUST set `season` or `team` to a non-null value for 
+ 750        this function to work. If you don't, a `ValueError()` 
+ 751        will be raised.
+ 752
+ 753    `team` (str, optional):
+ 754        Semi-ptional argument.
+ 755        If you only want team PPA data for a specific team,
+ 756        set `team` to the name of the team you want team PPA data from.
+ 757        You MUST set `season` or `team` to a non-null value for 
+ 758        this function to work. If you don't, a `ValueError()` 
+ 759        will be raised.
+ 760
+ 761    `conference_abv` (str, optional):
+ 762        Optional argument.
+ 763        If you only want team PPA data from games 
+ 764        involving teams from a specific confrence, 
+ 765        set `conference_abv` to the abbreviation 
+ 766        of the conference you want team PPA data from.
+ 767        For a list of confrences, 
+ 768        use the `cfbd_json_py.conferences.get_cfbd_conference_info()`
+ 769        function.
+ 770
+ 771    `return_as_dict` (bool, semi-optional):
+ 772        Semi-optional argument.
+ 773        If you want this function to return the data as a dictionary (read: JSON object), 
+ 774        instead of a pandas `DataFrame` object,
+ 775        set `return_as_dict` to `True`.
+ 776
+ 777    Usage
+ 778    ----------
+ 779    ```
+ 780    import time
+ 781
+ 782    from cfbd_json_py.players import get_cfbd_returning_production
+ 783
+ 784
+ 785    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+ 786
+ 787    if cfbd_key != "tigersAreAwsome":
+ 788        print("Using the user's API key declared in this script for this example.")
+ 789
+ 790        # Get returning production for teams who competed in the 2020 CFB season.
+ 791        print("Get returning production for teams who competed in the 2020 CFB season.")
+ 792        json_data = get_cfbd_returning_production(
+ 793            api_key=cfbd_key,
+ 794            season=2020
+ 795        )
+ 796        print(json_data)
+ 797        time.sleep(5)
+ 798
+ 799        # Get historical returning production for the Ohio Bobcats Football Team.
+ 800        print("Get historical returning production for the Ohio Bobcats Football Team.")
+ 801        json_data = get_cfbd_returning_production(
+ 802            api_key=cfbd_key,
+ 803            team="Ohio"
+ 804        )
+ 805        print(json_data)
+ 806        time.sleep(5)
+ 807
+ 808        # Get returning production for the 2019 LSU Tigers.
+ 809        print("Get returning production for the 2019 LSU Tigers.")
+ 810        json_data = get_cfbd_returning_production(
+ 811            api_key=cfbd_key,
+ 812            season=2019,
+ 813            team="LSU"
+ 814        )
+ 815        print(json_data)
+ 816        time.sleep(5)
+ 817
+ 818        # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.
+ 819        print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.")
+ 820        json_data = get_cfbd_returning_production(
+ 821            api_key=cfbd_key,
+ 822            team="Maryland",
+ 823            conference_abv="B1G"
+ 824        )
+ 825        print(json_data)
+ 826        time.sleep(5)
+ 827
+ 828        # Get returning production .
+ 829        print("Get returning production for the 2019 LSU Tigers.")
+ 830        json_data = get_cfbd_returning_production(
+ 831            api_key=cfbd_key,
+ 832            season=2019,
+ 833            team="LSU"
+ 834        )
+ 835        print(json_data)
+ 836        time.sleep(5)
+ 837
+ 838        # You can also tell this function to just return the API call as
+ 839        # a Dictionary (read: JSON) object.
+ 840        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 841        json_data = get_cfbd_returning_production(
+ 842            api_key=cfbd_key,
+ 843            season=2020,
+ 844            team="LSU",
+ 845            return_as_dict=True
+ 846        )
+ 847        print(json_data)
+ 848
+ 849    else:
+ 850        # Alternatively, if the CFBD API key exists in this python environment,
+ 851        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+ 852        # you could just call these functions directly, without setting the API key
+ 853        # in the script.
+ 854        print("Using the user's API key suposedly loaded into this python environment for this example.")
+ 855
+ 856        # Get returning production for teams who competed in the 2020 CFB season.
+ 857        print("Get returning production for teams who competed in the 2020 CFB season.")
+ 858        json_data = get_cfbd_returning_production(
+ 859            season=2020
+ 860        )
+ 861        print(json_data)
+ 862        time.sleep(5)
+ 863
+ 864        # Get historical returning production for the Ohio Bobcats Football Team.
+ 865        print("Get historical returning production for the Ohio Bobcats Football Team.")
+ 866        json_data = get_cfbd_returning_production(
+ 867            team="Ohio"
+ 868        )
+ 869        print(json_data)
+ 870        time.sleep(5)
+ 871
+ 872        # Get returning production for the 2019 LSU Tigers.
+ 873        print("Get returning production for the 2019 LSU Tigers.")
+ 874        json_data = get_cfbd_returning_production(
+ 875            season=2019,
+ 876            team="LSU"
+ 877        )
+ 878        print(json_data)
+ 879        time.sleep(5)
+ 880
+ 881        # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.
+ 882        print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.")
+ 883        json_data = get_cfbd_returning_production(
+ 884            team="Maryland",
+ 885            conference_abv="B1G"
+ 886        )
+ 887        print(json_data)
+ 888        time.sleep(5)
+ 889
+ 890        # Get returning production .
+ 891        print("Get returning production for the 2019 LSU Tigers.")
+ 892        json_data = get_cfbd_returning_production(
+ 893            season=2019,
+ 894            team="LSU"
+ 895        )
+ 896        print(json_data)
+ 897        time.sleep(5)
+ 898
+ 899        # You can also tell this function to just return the API call as
+ 900        # a Dictionary (read: JSON) object.
+ 901        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 902        json_data = get_cfbd_returning_production(
+ 903            season=2020,
+ 904            team="LSU",
+ 905            return_as_dict=True
+ 906        )
+ 907        print(json_data)
+ 908
+ 909    ```
+ 910    Returns
+ 911    ----------
+ 912    A pandas `DataFrame` object with returning production data, 
+ 913    or (if `return_as_dict` is set to `True`) 
+ 914    a dictionary object with returning production data.
+ 915
+ 916    """
+ 917    now = datetime.now()
+ 918    team_df = pd.DataFrame()
+ 919    row_df = pd.DataFrame()
+ 920    url = "https://api.collegefootballdata.com/player/returning"
+ 921
+ 922    ########################################################################################################################################################################################################
+ 923
+ 924    if api_key != None:
+ 925        real_api_key = api_key
+ 926        del api_key
+ 927    else:
+ 928        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+ 929
+ 930    if real_api_key == "tigersAreAwsome":
+ 931        raise ValueError(
+ 932            "You actually need to change `cfbd_key` to your CFBD API key.")
+ 933    elif "Bearer " in real_api_key:
+ 934        pass
+ 935    elif "Bearer" in real_api_key:
+ 936        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+ 937    else:
+ 938        real_api_key = "Bearer " + real_api_key
+ 939
+ 940    if season == None and team == None:
+ 941        raise ValueError(
+ 942            "To use this function, `season` and/or `team` must be set to a " +
+ 943            "non-null variable."
+ 944        )
+ 945
+ 946    if season == None:
+ 947        # Rare, but in this endpoint,
+ 948        # you don't need to input the season.
+ 949        pass
+ 950    elif season > (now.year + 1):
+ 951        raise ValueError(f"`season` cannot be greater than {season}.")
+ 952    elif season < 1869:
+ 953        raise ValueError(f"`season` cannot be less than 1869.")
+ 954
+ 955    # URL Builder
+ 956    ########################################################################################################################################################################################################
+ 957    url_elements = 0
+ 958
+ 959    if season != None and url_elements == 0:
+ 960        url += f"?year={season}"
+ 961        url_elements += 1
+ 962    elif season != None:
+ 963        url += f"&year={season}"
+ 964        url_elements += 1
+ 965
+ 966    if team != None and url_elements == 0:
+ 967        url += f"?team={team}"
+ 968        url_elements += 1
+ 969    elif team != None:
+ 970        url += f"&team={team}"
+ 971        url_elements += 1
+ 972
+ 973    if conference_abv != None and url_elements == 0:
+ 974        url += f"?conference={conference_abv}"
+ 975        url_elements += 1
+ 976    elif conference_abv != None:
+ 977        url += f"&conference={conference_abv}"
+ 978        url_elements += 1
+ 979
+ 980    headers = {
+ 981        'Authorization': f'{real_api_key}',
+ 982        'accept': 'application/json'
+ 983    }
+ 984
+ 985    response = requests.get(url, headers=headers)
+ 986
+ 987    if response.status_code == 200:
+ 988        pass
+ 989    elif response.status_code == 401:
+ 990        raise ConnectionRefusedError(
+ 991            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+ 992        )
+ 993    else:
+ 994        raise ConnectionError(
+ 995            f'Could not connect.\nHTTP Status code {response.status_code}'
+ 996        )
+ 997
+ 998    json_data = response.json()
+ 999
+1000    if return_as_dict == True:
+1001        return json_data
+1002
+1003    for team in tqdm(json_data):
+1004        t_season = team['season']
+1005        t_conference = team['conference']
+1006        t_name = team['team']
+1007
+1008        row_df = pd.DataFrame(
+1009            {
+1010                "season": t_season,
+1011                "team_name": t_name,
+1012                "team_conference": t_conference
+1013            },
+1014            index=[0]
+1015        )
+1016        row_df['total_ppa'] = team['totalPPA']
+1017        row_df['total_ppa_passing'] = team['totalPassingPPA']
+1018        row_df['total_ppa_rushing'] = team['totalRushingPPA']
+1019        row_df['total_ppa_receiving'] = team['totalReceivingPPA']
+1020        row_df['percent_ppa'] = team['percentPPA']
+1021        row_df['percent_ppa_passing'] = team['percentPassingPPA']
+1022        row_df['percent_ppa_rushing'] = team['percentRushingPPA']
+1023        row_df['percent_ppa_receiving'] = team['percentReceivingPPA']
+1024        row_df['usage'] = team['usage']
+1025        row_df['passing_usage'] = team['passingUsage']
+1026        row_df['rushing_usage'] = team['rushingUsage']
+1027        row_df['receiving_usage'] = team['receivingUsage']
+1028
+1029        team_df = pd.concat([team_df, row_df], ignore_index=True)
+1030
+1031        del row_df
+1032        del t_season, t_conference, t_name
+1033
+1034    return team_df
+1035
+1036
+1037def get_cfbd_player_season_stats(
+1038        season: int,
+1039        api_key: str = None,
+1040        api_key_dir: str = None,
+1041        team: str = None,
+1042        conference_abv: str = None,
+1043        start_week: int = None,
+1044        end_week: int = None,
+1045        season_type: str = "both",  # "regular", "postseason", or "both"
+1046        stat_category: str = None,
+1047        return_as_dict: bool = False):
+1048    """
+1049    Get player season stats, or the stats of players in a specific timeframe, from the CFBD API.
+1050
+1051    Parameters
+1052    ----------
+1053    `season` (int, mandatory):
+1054        Required argument.
+1055        Specifies the season you want CFB player season stats from.
+1056        This must be specified, otherwise this package, and by extension
+1057        the CFBD API, will not accept the request to get CFB player season stats.
+1058
+1059    `api_key` (str, optional):
+1060        Semi-optional argument. 
+1061        If `api_key` is null, this function will attempt to load a CFBD API key
+1062        from the python environment, or from a file on this computer.
+1063        If `api_key` is not null, this function will automatically assume that the
+1064        inputted `api_key` is a valid CFBD API key.
+1065
+1066    `api_key_dir` (str, optional):
+1067        Optional argument.
+1068        If `api_key` is set to am empty string, this variable is ignored.
+1069        If `api_key_dir` is null, and `api_key` is null, 
+1070        this function will try to find a CFBD API key file in this user's home directory.
+1071        If `api_key_dir` is set to a string, and `api_key` is null,
+1072        this function will assume that `api_key_dir` is a directory, 
+1073        and will try to find a CFBD API key file in that directory.
+1074
+1075    `team` (str, optional):
+1076        Optional argument.
+1077        If you only want CFB player season stats for a team, 
+1078        regardless if they are the home/away team,
+1079        set `team` to the name of the team you want CFB player season stats from.
+1080
+1081    `conference_abv` (str, optional):
+1082        Optional argument.
+1083        If you only want player season stats from games 
+1084        involving teams a specific confrence, 
+1085        set `conference_abv` to the abbreviation 
+1086        of the conference you want stats from.
+1087
+1088    `start_week` (int, semi-optional):
+1089        Optional argument.
+1090        If you only want player stats for a range of weeks, 
+1091        set `start_week` and `end_week` to 
+1092        the range of weeks you want season-level data for.
+1093
+1094    `end_week` (int, semi-optional):
+1095        Optional argument.
+1096        If you only want player stats for a range of weeks, 
+1097        set `start_week` and `end_week` to 
+1098        the range of weeks you want season-level data for.
+1099
+1100    **NOTE**: If the following conditions are `True`, a `ValueError()` 
+1101    will be raised when calling this function:
+1102    - `start_week < 0`
+1103    - `end_week < 0`
+1104    - `start_week != None and end_week == None` (will be changed in a future version)
+1105    - `start_week == None and end_week != None` (will be changed in a future version)
+1106    - `end_week < start_week`
+1107    - `end_week = start_week`
+1108
+1109    `season_type` (str, semi-optional):
+1110        Semi-optional argument.
+1111        By defualt, this will be set to "regular", for the CFB regular season.
+1112        If you want CFB media information for non-regular season games, 
+1113        set `season_type` to "postseason".
+1114        If you want ***both*** regular and postseason stats, set `season_type = "both"`.
+1115        If `season_type` is set to anything but "regular", "postseason",  or "both", 
+1116        a `ValueError()` will be raised.
+1117
+1118    `stat_category` (str, optional):
+1119        Optional argument.
+1120        If only want stats for a specific stat category, 
+1121        set this variable to that category.
+1122
+1123        Valid inputs are:
+1124        - `passing`
+1125        - `rushing`
+1126        - `receiving`
+1127        - `fumbles`
+1128        - `defensive`
+1129        - `interceptions`
+1130        - `punting`
+1131        - `kicking`
+1132        - `kickReturns`
+1133        - `puntReturns`
+1134
+1135    `return_as_dict` (bool, semi-optional):
+1136        Semi-optional argument.
+1137        If you want this function to return the data as a dictionary (read: JSON object), 
+1138        instead of a pandas `DataFrame` object,
+1139        set `return_as_dict` to `True`.
+1140
+1141    Usage
+1142    ----------
+1143    ```
+1144    import time
+1145
+1146    from cfbd_json_py.players import get_cfbd_player_season_stats
+1147
+1148
+1149    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+1150
+1151    if cfbd_key != "tigersAreAwsome":
+1152        print("Using the user's API key declared in this script for this example.")
+1153
+1154        # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.
+1155        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.")
+1156        json_data = get_cfbd_player_season_stats(
+1157            api_key=cfbd_key,
+1158            season=2020,
+1159            team="Ohio"
+1160        )
+1161        print(json_data)
+1162        time.sleep(5)
+1163
+1164        # Get player season stats for teams who competed in 
+1165        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1166        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1167        json_data = get_cfbd_player_season_stats(
+1168            api_key=cfbd_key,
+1169            season=2020,
+1170            conference_abv="SEC"
+1171        )
+1172        print(json_data)
+1173        time.sleep(5)
+1174
+1175        # Get player season stats for teams who competed in 
+1176        # the Southeastern Confrence (SEC) in the 2023 CFB season,
+1177        # but only between weeks 1 and 5.
+1178        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1179        json_data = get_cfbd_player_season_stats(
+1180            api_key=cfbd_key,
+1181            season=2020,
+1182            conference_abv="SEC",
+1183            start_week=1,
+1184            end_week=5
+1185        )
+1186        print(json_data)
+1187        time.sleep(5)
+1188
+1189
+1190        # Get player season stats for the 2020 CFB season.
+1191        print("Get player season stats for the 2020 CFB season.")
+1192        json_data = get_cfbd_player_season_stats(
+1193            api_key=cfbd_key,
+1194            season=2020
+1195        )
+1196        print(json_data)
+1197        time.sleep(5)
+1198
+1199
+1200        # Get player season stats for 
+1201        # the Ohio Bobcats Football team in the 2022 CFB season, 
+1202        # but only use regular season games when calculating season stats.
+1203        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.")
+1204        json_data = get_cfbd_player_season_stats(
+1205            api_key=cfbd_key,
+1206            season=2022,
+1207            team="Ohio",
+1208            season_type="regular"
+1209        )
+1210        print(json_data)
+1211        time.sleep(5)
+1212
+1213        # Get passing stats for teams who competed in 
+1214        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1215        print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1216        json_data = get_cfbd_player_season_stats(
+1217            api_key=cfbd_key,
+1218            season=2020,
+1219            conference_abv="SEC",
+1220            stat_category="passing"
+1221        )
+1222        print(json_data)
+1223        time.sleep(5)
+1224
+1225        # You can also tell this function to just return the API call as
+1226        # a Dictionary (read: JSON) object.
+1227        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+1228        json_data = get_cfbd_player_season_stats(
+1229            api_key=cfbd_key,
+1230            season=2020,
+1231            team="LSU",
+1232            stat_category="kicking",
+1233            return_as_dict=True
+1234        )
+1235        print(json_data)
+1236
+1237    else:
+1238        # Alternatively, if the CFBD API key exists in this python environment,
+1239        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+1240        # you could just call these functions directly, without setting the API key
+1241        # in the script.
+1242        print("Using the user's API key suposedly loaded into this python environment for this example.")
+1243
+1244        # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.
+1245        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.")
+1246        json_data = get_cfbd_player_season_stats(
+1247            season=2020,
+1248            team="Ohio"
+1249        )
+1250        print(json_data)
+1251        time.sleep(5)
+1252
+1253        # Get player season stats for teams who competed in 
+1254        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1255        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1256        json_data = get_cfbd_player_season_stats(
+1257            season=2020,
+1258            conference_abv="SEC"
+1259        )
+1260        print(json_data)
+1261        time.sleep(5)
+1262
+1263        # Get player season stats for teams who competed in 
+1264        # the Southeastern Confrence (SEC) in the 2023 CFB season,
+1265        # but only between weeks 1 and 5.
+1266        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1267        json_data = get_cfbd_player_season_stats(
+1268            season=2020,
+1269            conference_abv="SEC",
+1270            start_week=1,
+1271            end_week=5
+1272        )
+1273        print(json_data)
+1274        time.sleep(5)
+1275
+1276
+1277        # Get player season stats for the 2020 CFB season.
+1278        print("Get player season stats for the 2020 CFB season.")
+1279        json_data = get_cfbd_player_season_stats(
+1280            season=2020
+1281        )
+1282        print(json_data)
+1283        time.sleep(5)
+1284
+1285
+1286        # Get player season stats for 
+1287        # the Ohio Bobcats Football team in the 2022 CFB season, 
+1288        # but only use regular season games when calculating season stats.
+1289        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.")
+1290        json_data = get_cfbd_player_season_stats(
+1291            season=2022,
+1292            team="Ohio",
+1293            season_type="regular"
+1294        )
+1295        print(json_data)
+1296        time.sleep(5)
+1297
+1298        # Get passing stats for teams who competed in 
+1299        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1300        print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1301        json_data = get_cfbd_player_season_stats(
+1302            season=2020,
+1303            conference_abv="SEC",
+1304            stat_category="passing"
+1305        )
+1306        print(json_data)
+1307        time.sleep(5)
+1308
+1309        # You can also tell this function to just return the API call as
+1310        # a Dictionary (read: JSON) object.
+1311        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+1312        json_data = get_cfbd_player_season_stats(
+1313            season=2020,
+1314            team="LSU",
+1315            stat_category="kicking",
+1316            return_as_dict=True
+1317        )
+1318        print(json_data)
+1319
+1320
+1321    ```
+1322    Returns
+1323    ----------
+1324    A pandas `DataFrame` object with a list of players who matched the search string, 
+1325    or (if `return_as_dict` is set to `True`) 
+1326    a dictionary object with a list of players who matched the search string.
+1327
+1328    """
+1329    
+1330    rebuilt_json = {}
+1331    stat_columns = [
+1332        'season',
+1333        'team_name',
+1334        'team_confrence',
+1335        'player_id',
+1336        'player_name',
+1337        # PASS
+1338        'passing_COMP',
+1339        'passing_ATT',
+1340        'passing_COMP%',
+1341        'passing_YDS',
+1342        'passing_AVG',
+1343        'passing_TD',
+1344        'passing_INT',
+1345        # RUSH
+1346        'rushing_CAR',
+1347        'rushing_YDS',
+1348        'rushing_AVG',
+1349        'rushing_TD',
+1350        'rushing_LONG',
+1351        # REC
+1352        'receiving_REC',
+1353        'receiving_YDS',
+1354        'receiving_AVG',
+1355        'receiving_TD',
+1356        'receiving_LONG',
+1357        # FUM
+1358        'fumbles_FUM',
+1359        'fumbles_LOST',
+1360        'fumbles_REC',
+1361        # DEFENSE
+1362        'defensive_TOT',
+1363        'defensive_SOLO',
+1364        'defensive_TFL',
+1365        'defensive_QB HUR',
+1366        'defensive_SACKS',
+1367        'defensive_PD',
+1368        'defensive_TD',
+1369        # INT
+1370        'interceptions_INT',
+1371        'interceptions_YDS',
+1372        'interceptions_TD',
+1373        # PUNT
+1374        'punting_NO',
+1375        'punting_YDS',
+1376        'punting_AVG',
+1377        'punting_TB',
+1378        'punting_In 20',
+1379        'punting_LONG',
+1380        # KICK
+1381        'kicking_FGM',
+1382        'kicking_FGA',
+1383        'kicking_FG%',
+1384        'kicking_LONG',
+1385        'kicking_XPM',
+1386        'kicking_XPA',
+1387        'kicking_XP%',
+1388        # KR
+1389        'kickReturns_NO',
+1390        'kickReturns_YDS',
+1391        'kickReturns_AVG',
+1392        'kickReturns_TD',
+1393        'kickReturns_LONG',
+1394        # PR
+1395        'puntReturns_NO',
+1396        'puntReturns_YDS',
+1397        'puntReturns_AVG',
+1398        'puntReturns_TD',
+1399        'puntReturns_LONG'
+1400    ]
+1401
+1402    now = datetime.now()
+1403    url = "https://api.collegefootballdata.com/stats/player/season"
+1404
+1405    final_df = pd.DataFrame()
+1406
+1407    if api_key != None:
+1408        real_api_key = api_key
+1409        del api_key
+1410    else:
+1411        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+1412
+1413    if real_api_key == "tigersAreAwsome":
+1414        raise ValueError(
+1415            "You actually need to change `cfbd_key` to your CFBD API key.")
+1416    elif "Bearer " in real_api_key:
+1417        pass
+1418    elif "Bearer" in real_api_key:
+1419        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+1420    else:
+1421        real_api_key = "Bearer " + real_api_key
+1422
+1423    if season == None:
+1424        # This should never happen without user tampering, but if it does,
+1425        # we need to raise an error, because the CFBD API will refuse this call without a valid season.
+1426        raise SystemError(
+1427            "I don't know how, I don't know why, " +
+1428            "but you managed to call this function while `season` was `None` (NULL)," +
+1429            " and the function got to this point in the code." +
+1430            "\nIf you have a GitHub account, " +
+1431            "please raise an issue on this python package's GitHub page:\n" +
+1432            "https://github.com/armstjc/cfbd-json-py/issues"
+1433        )
+1434    elif season > (now.year + 1):
+1435        raise ValueError(f"`season` cannot be greater than {season}.")
+1436    elif season < 1869:
+1437        raise ValueError(f"`season` cannot be less than 1869.")
+1438
+1439    if season_type != "regular" and season_type != "postseason" and season_type != "both":
+1440        raise ValueError(
+1441            "`season_type` must be set to either \"regular\" or " +
+1442            "\"postseason\" for this function to work."
+1443        )
+1444
+1445    filter_by_stat_category = False
+1446
+1447    if stat_category == None:
+1448        pass
+1449    elif stat_category == "passing":
+1450        filter_by_stat_category = True
+1451    elif stat_category == "rushing":
+1452        filter_by_stat_category = True
+1453    elif stat_category == "receiving":
+1454        filter_by_stat_category = True
+1455    elif stat_category == "fumbles":
+1456        filter_by_stat_category = True
+1457    elif stat_category == "passing":
+1458        filter_by_stat_category = True
+1459    elif stat_category == "defensive":
+1460        filter_by_stat_category = True
+1461    elif stat_category == "interceptions":
+1462        filter_by_stat_category = True
+1463    elif stat_category == "punting":
+1464        filter_by_stat_category = True
+1465    elif stat_category == "kicking":
+1466        filter_by_stat_category = True
+1467    elif stat_category == "kickReturns":
+1468        filter_by_stat_category = True
+1469    elif stat_category == "puntReturns":
+1470        filter_by_stat_category = True
+1471    else:
+1472        raise ValueError(
+1473            "Invalid input for `stat_category`." +
+1474            "\nValid inputs are:" +
+1475            """
+1476            - `passing`
+1477            - `rushing`
+1478            - `receiving`
+1479            - `fumbles`
+1480            - `defensive`
+1481            - `interceptions`
+1482            - `punting`
+1483            - `kicking`
+1484            - `kickReturns`
+1485            - `puntReturns`
+1486            """
+1487        )
+1488
+1489    if start_week != None and end_week != None:
+1490        if start_week > end_week:
+1491            raise ValueError(
+1492                "`start_week` cannot be greater than `end_week`."
+1493            )
+1494        elif start_week == end_week:
+1495            raise ValueError(
+1496                "`start_week` cannot be equal to `end_week`." +
+1497                "\n Use `cfbd_json_py.games.get_cfbd_player_game_stats()` instead " +
+1498                "if you want player stats for a specific week in ."
+1499            )
+1500        elif start_week < 0:
+1501            raise ValueError(
+1502                "`start_week` cannot be less than 0."
+1503            )
+1504        elif end_week < 0:
+1505            raise ValueError(
+1506                "`end_week` cannot be less than 0."
+1507            )
+1508    #
+1509    # elif start_week != None and end_week == None:
+1510    #     raise ValueError(
+1511    #         "At this time, if you want to get season stats for a range of weeks " +
+1512    #         "`start_week` and `end_week` must be set to valid integers," +
+1513    #         " and not just `start_week`."
+1514    #     )
+1515    # elif start_week == None and end_week != None:
+1516    #     raise ValueError(
+1517    #         "At this time, if you want to get season stats for a range of weeks " +
+1518    #         "`start_week` and `end_week` must be set to valid integers," +
+1519    #         " and not just `end_week`."
+1520    #     )
+1521
+1522    if filter_by_stat_category == True:
+1523        pass
+1524
+1525    # URL builder
+1526    ########################################################################################################################################################################################################
+1527
+1528    # Required by the API
+1529    url += f"?year={season}"
+1530
+1531    if team != None:
+1532        url += f"&team={team}"
+1533
+1534    if conference_abv != None:
+1535        url += f"&conference={conference_abv}"
+1536
+1537    if season_type != None:
+1538        url += f"&seasonType={season_type}"
+1539
+1540    if stat_category != None:
+1541        url += f"&category={stat_category}"
+1542
+1543    if start_week != None:
+1544        url += f"&startWeek={start_week}"
+1545
+1546    if end_week != None:
+1547        url += f"&endWeek={end_week}"
+1548
+1549    headers = {
+1550        'Authorization': f'{real_api_key}',
+1551        'accept': 'application/json'
+1552    }
+1553
+1554    response = requests.get(url, headers=headers)
+1555
+1556    if response.status_code == 200:
+1557        pass
+1558    elif response.status_code == 401:
+1559        raise ConnectionRefusedError(
+1560            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+1561        )
+1562    else:
+1563        raise ConnectionError(
+1564            f'Could not connect.\nHTTP Status code {response.status_code}'
+1565        )
+1566
+1567    json_data = response.json()
+1568
+1569    if return_as_dict == True:
+1570        return json_data
+1571
+1572    for player in tqdm(json_data):
+1573        player_id = int(player['playerId'])
+1574        player_name = player['player']
+1575        team_name = player['team']
+1576        team_confrence = player['conference']
+1577        s_category = player['category']
+1578        s_type = player['statType']
+1579        s_num = player['stat']
+1580
+1581        if rebuilt_json.get(player_id) == None:
+1582            rebuilt_json[player_id] = {}
+1583
+1584        if s_category == "passing":
+1585            if s_type == "COMPLETIONS":
+1586                rebuilt_json[player_id]['player_name'] = player_name
+1587                rebuilt_json[player_id]['team_name'] = team_name
+1588                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1589                rebuilt_json[player_id]['passing_COMP'] = s_num
+1590
+1591            elif s_type == "ATT":
+1592                rebuilt_json[player_id]['player_name'] = player_name
+1593                rebuilt_json[player_id]['team_name'] = team_name
+1594                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1595                rebuilt_json[player_id]['passing_ATT'] = s_num
+1596
+1597            elif s_type == "YDS":
+1598                rebuilt_json[player_id]['player_name'] = player_name
+1599                rebuilt_json[player_id]['team_name'] = team_name
+1600                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1601                rebuilt_json[player_id]['passing_YDS'] = s_num
+1602
+1603            elif s_type == "TD":
+1604                rebuilt_json[player_id]['player_name'] = player_name
+1605                rebuilt_json[player_id]['team_name'] = team_name
+1606                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1607                rebuilt_json[player_id]['passing_TD'] = s_num
+1608
+1609            elif s_type == "INT":
+1610                rebuilt_json[player_id]['player_name'] = player_name
+1611                rebuilt_json[player_id]['team_name'] = team_name
+1612                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1613                rebuilt_json[player_id]['passing_INT'] = s_num
+1614            # we can calculate these two later
+1615            elif s_type == "PCT":
+1616                pass
+1617
+1618            elif s_type == "YPA":
+1619                pass
+1620
+1621            else:
+1622                raise ValueError(f"Unhandled stat type: {s_type}")
+1623
+1624        elif s_category == "rushing":
+1625            if s_type == "CAR":
+1626                rebuilt_json[player_id]['player_name'] = player_name
+1627                rebuilt_json[player_id]['team_name'] = team_name
+1628                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1629                rebuilt_json[player_id]['rushing_CAR'] = s_num
+1630
+1631            elif s_type == "YDS":
+1632                rebuilt_json[player_id]['player_name'] = player_name
+1633                rebuilt_json[player_id]['team_name'] = team_name
+1634                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1635                rebuilt_json[player_id]['rushing_YDS'] = s_num
+1636
+1637            elif s_type == "TD":
+1638                rebuilt_json[player_id]['player_name'] = player_name
+1639                rebuilt_json[player_id]['team_name'] = team_name
+1640                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1641                rebuilt_json[player_id]['rushing_TD'] = s_num
+1642
+1643            elif s_type == "LONG":
+1644                rebuilt_json[player_id]['player_name'] = player_name
+1645                rebuilt_json[player_id]['team_name'] = team_name
+1646                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1647                rebuilt_json[player_id]['rushing_LONG'] = s_num
+1648            # we can calculate this later
+1649            elif s_type == "YPC":
+1650                pass
+1651
+1652            else:
+1653                raise ValueError(f"Unhandled stat type: {s_type}")
+1654
+1655        elif s_category == "receiving":
+1656            if s_type == "REC":
+1657                rebuilt_json[player_id]['player_name'] = player_name
+1658                rebuilt_json[player_id]['team_name'] = team_name
+1659                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1660                rebuilt_json[player_id]['receiving_REC'] = s_num
+1661
+1662            elif s_type == "YDS":
+1663                rebuilt_json[player_id]['player_name'] = player_name
+1664                rebuilt_json[player_id]['team_name'] = team_name
+1665                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1666                rebuilt_json[player_id]['receiving_YDS'] = s_num
+1667
+1668            elif s_type == "TD":
+1669                rebuilt_json[player_id]['player_name'] = player_name
+1670                rebuilt_json[player_id]['team_name'] = team_name
+1671                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1672                rebuilt_json[player_id]['receiving_TD'] = s_num
+1673
+1674            elif s_type == "LONG":
+1675                rebuilt_json[player_id]['player_name'] = player_name
+1676                rebuilt_json[player_id]['team_name'] = team_name
+1677                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1678                rebuilt_json[player_id]['receiving_LONG'] = s_num
+1679            # we can calculate this later
+1680            elif s_type == "YPR":
+1681                pass
+1682
+1683            else:
+1684                raise ValueError(f"Unhandled stat type: {s_type}")
+1685
+1686        elif s_category == "fumbles":
+1687            if s_type == "FUM":
+1688                rebuilt_json[player_id]['player_name'] = player_name
+1689                rebuilt_json[player_id]['team_name'] = team_name
+1690                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1691                rebuilt_json[player_id]['fumbles_FUM'] = s_num
+1692
+1693            elif s_type == "LOST":
+1694                rebuilt_json[player_id]['player_name'] = player_name
+1695                rebuilt_json[player_id]['team_name'] = team_name
+1696                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1697                rebuilt_json[player_id]['fumbles_LOST'] = s_num
+1698
+1699            elif s_type == "REC":
+1700                rebuilt_json[player_id]['player_name'] = player_name
+1701                rebuilt_json[player_id]['team_name'] = team_name
+1702                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1703                rebuilt_json[player_id]['fumbles_LOST'] = s_num
+1704
+1705            else:
+1706                raise ValueError(f"Unhandled stat type: {s_type}")
+1707
+1708        elif s_category == "defensive":
+1709            if s_type == "TOT":
+1710                rebuilt_json[player_id]['player_name'] = player_name
+1711                rebuilt_json[player_id]['team_name'] = team_name
+1712                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1713                rebuilt_json[player_id]['defensive_TOT'] = s_num
+1714
+1715            elif s_type == "SOLO":
+1716                rebuilt_json[player_id]['player_name'] = player_name
+1717                rebuilt_json[player_id]['team_name'] = team_name
+1718                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1719                rebuilt_json[player_id]['defensive_SOLO'] = s_num
+1720
+1721            elif s_type == "TFL":
+1722                rebuilt_json[player_id]['player_name'] = player_name
+1723                rebuilt_json[player_id]['team_name'] = team_name
+1724                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1725                rebuilt_json[player_id]['defensive_TFL'] = s_num
+1726
+1727            elif s_type == "QB HUR":
+1728                rebuilt_json[player_id]['player_name'] = player_name
+1729                rebuilt_json[player_id]['team_name'] = team_name
+1730                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1731                rebuilt_json[player_id]['defensive_QB HUR'] = s_num
+1732
+1733            elif s_type == "SACKS":
+1734                rebuilt_json[player_id]['player_name'] = player_name
+1735                rebuilt_json[player_id]['team_name'] = team_name
+1736                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1737                rebuilt_json[player_id]['defensive_SACKS'] = s_num
+1738
+1739            elif s_type == "PD":
+1740                rebuilt_json[player_id]['player_name'] = player_name
+1741                rebuilt_json[player_id]['team_name'] = team_name
+1742                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1743                rebuilt_json[player_id]['defensive_PD'] = s_num
+1744
+1745            elif s_type == "TD":
+1746                rebuilt_json[player_id]['player_name'] = player_name
+1747                rebuilt_json[player_id]['team_name'] = team_name
+1748                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1749                rebuilt_json[player_id]['defensive_TD'] = s_num
+1750
+1751            else:
+1752                raise ValueError(f"Unhandled stat type: {s_type}")
+1753
+1754        elif s_category == "interceptions":
+1755            if s_type == "INT":
+1756                rebuilt_json[player_id]['player_name'] = player_name
+1757                rebuilt_json[player_id]['team_name'] = team_name
+1758                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1759                rebuilt_json[player_id]['interceptions_INT'] = s_num
+1760
+1761            elif s_type == "YDS":
+1762                rebuilt_json[player_id]['player_name'] = player_name
+1763                rebuilt_json[player_id]['team_name'] = team_name
+1764                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1765                rebuilt_json[player_id]['interceptions_YDS'] = s_num
+1766
+1767            elif s_type == "TD":
+1768                rebuilt_json[player_id]['player_name'] = player_name
+1769                rebuilt_json[player_id]['team_name'] = team_name
+1770                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1771                rebuilt_json[player_id]['interceptions_TD'] = s_num
+1772
+1773            elif s_type == "AVG":
+1774                pass
+1775
+1776            else:
+1777                raise ValueError(f"Unhandled stat type: {s_type}")
+1778
+1779        elif s_category == "punting":
+1780            if s_type == "NO":
+1781                rebuilt_json[player_id]['player_name'] = player_name
+1782                rebuilt_json[player_id]['team_name'] = team_name
+1783                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1784                rebuilt_json[player_id]['punting_NO'] = s_num
+1785
+1786            elif s_type == "YDS":
+1787                rebuilt_json[player_id]['player_name'] = player_name
+1788                rebuilt_json[player_id]['team_name'] = team_name
+1789                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1790                rebuilt_json[player_id]['punting_YDS'] = s_num
+1791
+1792            elif s_type == "TB":
+1793                rebuilt_json[player_id]['player_name'] = player_name
+1794                rebuilt_json[player_id]['team_name'] = team_name
+1795                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1796                rebuilt_json[player_id]['punting_TB'] = s_num
+1797
+1798            elif s_type == "In 20":
+1799                rebuilt_json[player_id]['player_name'] = player_name
+1800                rebuilt_json[player_id]['team_name'] = team_name
+1801                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1802                rebuilt_json[player_id]['punting_In 20'] = s_num
+1803
+1804            elif s_type == "LONG":
+1805                rebuilt_json[player_id]['player_name'] = player_name
+1806                rebuilt_json[player_id]['team_name'] = team_name
+1807                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1808                rebuilt_json[player_id]['punting_LONG'] = s_num
+1809
+1810            elif s_type == "YPP":
+1811                pass
+1812
+1813            else:
+1814                raise ValueError(f"Unhandled stat type: {s_type}")
+1815
+1816        elif s_category == "kicking":
+1817            if s_type == "FGM":
+1818                rebuilt_json[player_id]['player_name'] = player_name
+1819                rebuilt_json[player_id]['team_name'] = team_name
+1820                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1821                rebuilt_json[player_id]['kicking_FGM'] = s_num
+1822
+1823            elif s_type == "FGA":
+1824                rebuilt_json[player_id]['player_name'] = player_name
+1825                rebuilt_json[player_id]['team_name'] = team_name
+1826                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1827                rebuilt_json[player_id]['kicking_FGA'] = s_num
+1828
+1829            elif s_type == "LONG":
+1830                rebuilt_json[player_id]['player_name'] = player_name
+1831                rebuilt_json[player_id]['team_name'] = team_name
+1832                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1833                rebuilt_json[player_id]['kicking_LONG'] = s_num
+1834
+1835            elif s_type == "XPM":
+1836                rebuilt_json[player_id]['player_name'] = player_name
+1837                rebuilt_json[player_id]['team_name'] = team_name
+1838                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1839                rebuilt_json[player_id]['kicking_XPM'] = s_num
+1840
+1841            elif s_type == "XPA":
+1842                rebuilt_json[player_id]['player_name'] = player_name
+1843                rebuilt_json[player_id]['team_name'] = team_name
+1844                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1845                rebuilt_json[player_id]['kicking_XPA'] = s_num
+1846
+1847            elif s_type == "PTS":
+1848                pass
+1849
+1850            elif s_type == "PCT":
+1851                pass
+1852
+1853            else:
+1854                raise ValueError(f"Unhandled stat type: {s_type}")
+1855
+1856        elif s_category == "kickReturns":
+1857            if s_type == "NO":
+1858                rebuilt_json[player_id]['player_name'] = player_name
+1859                rebuilt_json[player_id]['team_name'] = team_name
+1860                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1861                rebuilt_json[player_id]['kickReturns_NO'] = s_num
+1862
+1863            elif s_type == "YDS":
+1864                rebuilt_json[player_id]['player_name'] = player_name
+1865                rebuilt_json[player_id]['team_name'] = team_name
+1866                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1867                rebuilt_json[player_id]['kickReturns_YDS'] = s_num
+1868
+1869            elif s_type == "TD":
+1870                rebuilt_json[player_id]['player_name'] = player_name
+1871                rebuilt_json[player_id]['team_name'] = team_name
+1872                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1873                rebuilt_json[player_id]['kickReturns_TD'] = s_num
+1874
+1875            elif s_type == "LONG":
+1876                rebuilt_json[player_id]['player_name'] = player_name
+1877                rebuilt_json[player_id]['team_name'] = team_name
+1878                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1879                rebuilt_json[player_id]['kickReturns_LONG'] = s_num
+1880            # we can calculate this later
+1881            elif s_type == "AVG":
+1882                pass
+1883
+1884            else:
+1885                raise ValueError(f"Unhandled stat type: {s_type}")
+1886
+1887        elif s_category == "puntReturns":
+1888            if s_type == "NO":
+1889                rebuilt_json[player_id]['player_name'] = player_name
+1890                rebuilt_json[player_id]['team_name'] = team_name
+1891                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1892                rebuilt_json[player_id]['puntReturns_NO'] = s_num
+1893
+1894            elif s_type == "YDS":
+1895                rebuilt_json[player_id]['player_name'] = player_name
+1896                rebuilt_json[player_id]['team_name'] = team_name
+1897                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1898                rebuilt_json[player_id]['puntReturns_YDS'] = s_num
+1899
+1900            elif s_type == "TD":
+1901                rebuilt_json[player_id]['player_name'] = player_name
+1902                rebuilt_json[player_id]['team_name'] = team_name
+1903                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1904                rebuilt_json[player_id]['puntReturns_TD'] = s_num
+1905
+1906            elif s_type == "LONG":
+1907                rebuilt_json[player_id]['player_name'] = player_name
+1908                rebuilt_json[player_id]['team_name'] = team_name
+1909                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1910                rebuilt_json[player_id]['puntReturns_LONG'] = s_num
+1911            # we can calculate this later
+1912            elif s_type == "AVG":
+1913                pass
+1914
+1915            else:
+1916                raise ValueError(f"Unhandled stat type: {s_type}")
+1917
+1918        else:
+1919            raise ValueError(f"Unhandled stat category: {s_category}")
+1920
+1921        del player_id, player_name, team_name, team_confrence,\
+1922            s_category, s_type, s_num
+1923
+1924    for key, value in tqdm(rebuilt_json.items()):
+1925        # print(key)
+1926
+1927        # print(value)
+1928        team_name = value['team_name']
+1929        team_confrence = value['team_confrence']
+1930        player_id = key
+1931        player_name = value['player_name']
+1932
+1933        row_df = pd.DataFrame(
+1934            {
+1935                "team_name": team_name,
+1936                "team_confrence": team_confrence,
+1937                "player_id": player_id,
+1938                "player_name": player_name
+1939            },
+1940            index=[0]
+1941        )
+1942        # Passing
+1943        if value.get('passing_COMP') != None:
+1944            row_df['passing_COMP'] = value['passing_COMP']
+1945
+1946        if value.get('passing_ATT') != None:
+1947            row_df['passing_ATT'] = value['passing_ATT']
+1948
+1949        if value.get('passing_YDS') != None:
+1950            row_df['passing_YDS'] = value['passing_YDS']
+1951
+1952        if value.get('passing_TD') != None:
+1953            row_df['passing_TD'] = value['passing_TD']
+1954
+1955        if value.get('passing_INT') != None:
+1956            row_df['passing_INT'] = value['passing_INT']
+1957
+1958        # Rushing
+1959        if value.get('rushing_CAR') != None:
+1960            row_df['rushing_CAR'] = value['rushing_CAR']
+1961
+1962        if value.get('rushing_YDS') != None:
+1963            row_df['rushing_YDS'] = value['rushing_YDS']
+1964
+1965        if value.get('rushing_AVG') != None:
+1966            row_df['rushing_AVG'] = value['rushing_AVG']
+1967
+1968        if value.get('rushing_TD') != None:
+1969            row_df['rushing_TD'] = value['rushing_TD']
+1970
+1971        if value.get('rushing_LONG') != None:
+1972            row_df['rushing_LONG'] = value['rushing_LONG']
+1973
+1974        # Receiving
+1975        if value.get('receiving_REC') != None:
+1976            row_df['receiving_REC'] = value['receiving_REC']
+1977
+1978        if value.get('receiving_YDS') != None:
+1979            row_df['receiving_YDS'] = value['receiving_YDS']
+1980
+1981        if value.get('receiving_TD') != None:
+1982            row_df['receiving_TD'] = value['receiving_TD']
+1983
+1984        if value.get('receiving_LONG') != None:
+1985            row_df['receiving_LONG'] = value['receiving_LONG']
+1986
+1987        # Fumbles
+1988        if value.get('fumbles_FUM') != None:
+1989            row_df['fumbles_FUM'] = value['fumbles_FUM']
+1990
+1991        if value.get('fumbles_LOST') != None:
+1992            row_df['fumbles_LOST'] = value['fumbles_LOST']
+1993
+1994        if value.get('fumbles_REC') != None:
+1995            row_df['fumbles_REC'] = value['fumbles_REC']
+1996
+1997        # Defense
+1998        if value.get('defensive_TOT') != None:
+1999            row_df['defensive_TOT'] = value['defensive_TOT']
+2000
+2001        if value.get('defensive_SOLO') != None:
+2002            row_df['defensive_SOLO'] = value['defensive_SOLO']
+2003
+2004        if value.get('defensive_TFL') != None:
+2005            row_df['defensive_TFL'] = value['defensive_TFL']
+2006
+2007        if value.get('defensive_QB HUR') != None:
+2008            row_df['defensive_QB HUR'] = value['defensive_QB HUR']
+2009
+2010        if value.get('defensive_SACKS') != None:
+2011            row_df['defensive_SACKS'] = value['defensive_SACKS']
+2012
+2013        if value.get('defensive_PD') != None:
+2014            row_df['defensive_PD'] = value['defensive_PD']
+2015
+2016        if value.get('defensive_TD') != None:
+2017            row_df['defensive_TD'] = value['defensive_TD']
+2018
+2019        # interceptions
+2020        if value.get('interceptions_INT') != None:
+2021            row_df['interceptions_INT'] = value['interceptions_INT']
+2022
+2023        if value.get('interceptions_YDS') != None:
+2024            row_df['interceptions_YDS'] = value['interceptions_YDS']
+2025
+2026        if value.get('interceptions_TD') != None:
+2027            row_df['interceptions_TD'] = value['interceptions_TD']
+2028
+2029        # punting
+2030        if value.get('punting_NO') != None:
+2031            row_df['punting_NO'] = value['punting_NO']
+2032
+2033        if value.get('punting_YDS') != None:
+2034            row_df['punting_YDS'] = value['punting_YDS']
+2035
+2036        if value.get('punting_TB') != None:
+2037            row_df['punting_TB'] = value['punting_TB']
+2038
+2039        if value.get('punting_In 20') != None:
+2040            row_df['punting_In 20'] = value['punting_In 20']
+2041
+2042        if value.get('punting_LONG') != None:
+2043            row_df['punting_LONG'] = value['punting_LONG']
+2044
+2045        # kicking
+2046        if value.get('kicking_FGM') != None:
+2047            row_df['kicking_FGM'] = value['kicking_FGM']
+2048
+2049        if value.get('kicking_FGA') != None:
+2050            row_df['kicking_FGA'] = value['kicking_FGA']
+2051
+2052        if value.get('kicking_LONG') != None:
+2053            row_df['kicking_LONG'] = value['kicking_LONG']
+2054
+2055        if value.get('kicking_XPM') != None:
+2056            row_df['kicking_XPM'] = value['kicking_XPM']
+2057
+2058        if value.get('kicking_XPA') != None:
+2059            row_df['kicking_XPA'] = value['kicking_XPA']
+2060
+2061        # kickReturns
+2062        if value.get('kickReturns_NO') != None:
+2063            row_df['kickReturns_NO'] = value['kickReturns_NO']
+2064
+2065        if value.get('kickReturns_YDS') != None:
+2066            row_df['kickReturns_YDS'] = value['kickReturns_YDS']
+2067
+2068        if value.get('kickReturns_AVG') != None:
+2069            row_df['kickReturns_AVG'] = value['kickReturns_AVG']
+2070
+2071        if value.get('kickReturns_TD') != None:
+2072            row_df['kickReturns_TD'] = value['kickReturns_TD']
+2073
+2074        if value.get('kickReturns_LONG') != None:
+2075            row_df['kickReturns_LONG'] = value['kickReturns_LONG']
+2076
+2077        # puntReturns
+2078        if value.get('puntReturns_NO') != None:
+2079            row_df['puntReturns_NO'] = value['puntReturns_NO']
+2080
+2081        if value.get('puntReturns_YDS') != None:
+2082            row_df['puntReturns_YDS'] = value['puntReturns_YDS']
+2083
+2084        if value.get('puntReturns_AVG') != None:
+2085            row_df['puntReturns_AVG'] = value['puntReturns_AVG']
+2086
+2087        if value.get('puntReturns_TD') != None:
+2088            row_df['puntReturns_TD'] = value['puntReturns_TD']
+2089
+2090        if value.get('puntReturns_LONG') != None:
+2091            row_df['puntReturns_LONG'] = value['puntReturns_LONG']
+2092
+2093        final_df = pd.concat([final_df, row_df], ignore_index=True)
+2094        del row_df
+2095
+2096    final_df = final_df.fillna(0)
+2097
+2098    final_df['season'] = season
+2099
+2100    if filter_by_stat_category == False:
+2101        final_df = final_df.reindex(columns=stat_columns)
+2102        final_df = final_df.astype({
+2103            "passing_COMP": "int",
+2104            "passing_ATT": "int",
+2105            "rushing_CAR": "int",
+2106            "rushing_YDS": "int",
+2107            "receiving_REC": "int",
+2108            "receiving_YDS": "int",
+2109            "punting_NO": "int",
+2110            "punting_YDS": "int",
+2111            "kicking_FGM": "int",
+2112            "kicking_FGA": "int",
+2113            "kicking_XPM": "int",
+2114            "kicking_XPA": "int",
+2115            "kickReturns_NO": "int",
+2116            "kickReturns_YDS": "int",
+2117            "puntReturns_NO": "int",
+2118            "puntReturns_YDS": "int",
+2119
+2120        })
+2121
+2122        final_df.loc[
+2123            final_df['passing_ATT'] > 0, 'passing_COMP%'] = final_df['passing_COMP'] / final_df['passing_ATT']
+2124
+2125        final_df.loc[
+2126            final_df['rushing_CAR'] > 0, 'rushing_AVG'] = final_df['rushing_YDS'] / final_df['rushing_CAR']
+2127
+2128        final_df.loc[
+2129            final_df['receiving_REC'] > 0, 'receiving_AVG'] = final_df['receiving_YDS']/final_df['receiving_REC']
+2130
+2131
+2132        final_df.loc[
+2133            final_df['punting_NO'] > 0, 'punting_AVG'] = final_df['punting_YDS']/final_df['punting_NO']
+2134
+2135        final_df.loc[
+2136            final_df['kicking_FGA'] > 0, 'kicking_FG%'] = final_df['kicking_FGM']/final_df['kicking_FGA']
+2137
+2138        final_df.loc[
+2139            final_df['kicking_XPA'] > 0, 'kicking_XP%'] = final_df['kicking_XPM']/final_df['kicking_XPA']
+2140
+2141        final_df.loc[
+2142            final_df['kickReturns_NO'] > 0, 'kickReturns_AVG'] = final_df['kickReturns_YDS']/final_df['kickReturns_NO']
+2143
+2144        final_df.loc[
+2145            final_df['puntReturns_NO'] > 0, 'puntReturns_AVG'] = final_df['puntReturns_YDS']/final_df['puntReturns_NO']
+2146
+2147
+2148    elif filter_by_stat_category == True and stat_category == "passing":
+2149        try:
+2150            final_df = final_df.astype({
+2151                "passing_COMP": "int",
+2152                "passing_ATT": "int",
+2153            })
+2154        except:
+2155            logging.warning(
+2156                "Could not reformat [passing_COMP] and [passing_ATT] into integers."
+2157            )
+2158
+2159        final_df.loc[
+2160            final_df['passing_ATT'] >= 1, 'passing_COMP%'] = final_df['passing_COMP'] / final_df['passing_ATT']
+2161
+2162        final_df = final_df[[
+2163            'season',
+2164            'team_name',
+2165            'team_confrence',
+2166            'player_id',
+2167            'player_name',
+2168            # PASS
+2169            'passing_COMP',
+2170            'passing_ATT',
+2171            'passing_YDS',
+2172            'passing_TD',
+2173            'passing_INT',
+2174        ]]
+2175
+2176    elif filter_by_stat_category == True and stat_category == "rushing":
+2177        try:
+2178            final_df = final_df.astype({
+2179                "rushing_CAR": "int",
+2180                "rushing_YDS": "int",
+2181            })
+2182        except:
+2183            logging.warning(
+2184                "Could not reformat [rushing_CAR] and [rushing_YDS] into integers."
+2185            )
+2186
+2187        final_df.loc[
+2188            final_df['rushing_CAR'] >= 1, 'rushing_AVG'] = final_df['rushing_YDS'] / final_df['rushing_CAR']
+2189
+2190        final_df = final_df[[
+2191            'season',
+2192            'team_name',
+2193            'team_confrence',
+2194            'player_id',
+2195            'player_name',
+2196            # RUSH
+2197            'rushing_CAR',
+2198            'rushing_YDS',
+2199            'rushing_AVG',
+2200            'rushing_TD',
+2201            'rushing_LONG',
+2202        ]]
+2203
+2204    elif filter_by_stat_category == True and stat_category == "receiving":
+2205        try:
+2206            final_df = final_df.astype({
+2207                "receiving_REC": "int",
+2208                "receiving_YDS": "int",
+2209            })
+2210        except:
+2211            logging.warning(
+2212                "Could not reformat [receiving_REC] and [receiving_YDS] into integers."
+2213            )
+2214
+2215        final_df.loc[
+2216            final_df['receiving_REC'] > 0, 'receiving_AVG'] = final_df['receiving_YDS']/final_df['receiving_REC']
+2217
+2218        final_df = final_df[[
+2219            'season',
+2220            'team_name',
+2221            'team_confrence',
+2222            'player_id',
+2223            'player_name',
+2224            # REC
+2225            'receiving_REC',
+2226            'receiving_YDS',
+2227            'receiving_AVG',
+2228            'receiving_TD',
+2229            'receiving_LONG'
+2230        ]]
+2231
+2232    elif filter_by_stat_category == True and stat_category == "fumbles":
+2233        final_df = final_df[[
+2234            'season',
+2235            'team_name',
+2236            'team_confrence',
+2237            'player_id',
+2238            'player_name',
+2239            # FUM
+2240            'fumbles_FUM',
+2241            'fumbles_LOST',
+2242            'fumbles_REC'
+2243        ]]
+2244
+2245    elif filter_by_stat_category == True and stat_category == "defensive":
+2246        final_df = final_df[[
+2247            'season',
+2248            'team_name',
+2249            'team_confrence',
+2250            'player_id',
+2251            'player_name',
+2252            # DEFENSE
+2253            'defensive_TOT',
+2254            'defensive_SOLO',
+2255            'defensive_TFL',
+2256            'defensive_QB HUR',
+2257            'defensive_SACKS',
+2258            'defensive_PD',
+2259            'defensive_TD'
+2260        ]]
+2261
+2262    elif filter_by_stat_category == True and stat_category == "interceptions":
+2263        final_df = final_df[[
+2264            'season',
+2265            'team_name',
+2266            'team_confrence',
+2267            'player_id',
+2268            'player_name',
+2269            # INT
+2270            'interceptions_INT',
+2271            'interceptions_YDS',
+2272            'interceptions_TD',
+2273        ]]
+2274
+2275    elif filter_by_stat_category == True and stat_category == "punting":
+2276        try:
+2277            final_df = final_df.astype({
+2278                "punting_NO": "int",
+2279                "punting_YDS": "int",
+2280            })
+2281        except:
+2282            logging.warning(
+2283                "Could not reformat [punting_YDS] and [punting_NO] into integers."
+2284            )
+2285
+2286        final_df.loc[
+2287            final_df['punting_NO'] > 0, 'punting_AVG'] = final_df['punting_YDS']/final_df['punting_NO']
+2288
+2289        final_df = final_df[[
+2290            'season',
+2291            'team_name',
+2292            'team_confrence',
+2293            'player_id',
+2294            'player_name',
+2295            # PUNT
+2296            'punting_NO',
+2297            'punting_YDS',
+2298            'punting_AVG',
+2299            'punting_TB',
+2300            'punting_In 20',
+2301            'punting_LONG'
+2302        ]]
+2303
+2304    elif filter_by_stat_category == True and stat_category == "kicking":
+2305        try:
+2306            final_df = final_df.astype({
+2307                "kicking_FGM": "int",
+2308                "kicking_FGA": "int",
+2309                "kicking_XPM": "int",
+2310                "kicking_XPA": "int"
+2311            })
+2312        except:
+2313            logging.warning(
+2314                "Could not reformat the following columns into integers.:"+
+2315                "\n-[kicking_FGM]"+
+2316                "\n-[kicking_FGA]"+
+2317                "\n-[kicking_XPM]"+
+2318                "\n-[kicking_XPA]"
+2319                
+2320            )
+2321
+2322        final_df.loc[
+2323            final_df['kicking_FGA'] > 0, 'kicking_FG%'] = final_df['kicking_FGM']/final_df['kicking_FGA']
+2324
+2325        final_df.loc[
+2326            final_df['kicking_XPA'] > 0, 'kicking_XP%'] = final_df['kicking_XPM']/final_df['kicking_XPA']
+2327
+2328        final_df = final_df[[
+2329            'season',
+2330            'team_name',
+2331            'team_confrence',
+2332            'player_id',
+2333            'player_name',
+2334            # KICK
+2335            'kicking_FGM',
+2336            'kicking_FGA',
+2337            'kicking_FG%',
+2338            'kicking_LONG',
+2339            'kicking_XPM',
+2340            'kicking_XPA'
+2341            'kicking_XP%',
+2342        ]]
+2343
+2344    elif filter_by_stat_category == True and stat_category == "kickReturns":
+2345        try:
+2346            final_df = final_df.astype({
+2347                "kickReturns_NO": "int",
+2348                "kickReturns_YDS": "int",
+2349            })
+2350        except:
+2351            logging.warning(
+2352                "Could not reformat [passing_COMP] and [kickReturns_YDS] into integers."
+2353            )
+2354
+2355
+2356        final_df.loc[
+2357            final_df['kickReturns_NO'] > 0, 'kickReturns_AVG'] = final_df['kickReturns_YDS']/final_df['kickReturns_NO']
+2358
+2359        final_df = final_df[[
+2360            'season',
+2361            'team_name',
+2362            'team_confrence',
+2363            'player_id',
+2364            'player_name',
+2365            # KR
+2366            'kickReturns_NO',
+2367            'kickReturns_YDS',
+2368            'kickReturns_AVG',
+2369            'kickReturns_TD',
+2370            'kickReturns_LONG'
+2371        ]]
+2372
+2373    elif filter_by_stat_category == True and stat_category == "puntReturns":
+2374        try:
+2375            final_df = final_df.astype({
+2376                "puntReturns_NO": "int",
+2377                "puntReturns_YDS": "int",
+2378            })
+2379        except:
+2380            logging.warning(
+2381                "Could not reformat [passing_COMP] and [puntReturns_YDS] into integers."
+2382            )
+2383
+2384
+2385        final_df.loc[
+2386            final_df['puntReturns_NO'] > 0, 'puntReturns_AVG'] = final_df['puntReturns_YDS']/final_df['puntReturns_NO']
+2387
+2388        final_df = final_df[[
+2389            'season',
+2390            'team_name',
+2391            'team_confrence',
+2392            'player_id',
+2393            'player_name',
+2394            # KR
+2395            'puntReturns_NO',
+2396            'puntReturns_YDS',
+2397            'puntReturns_AVG',
+2398            'puntReturns_TD',
+2399            'puntReturns_LONG'
+2400        ]]
+2401
+2402    return final_df
+2403
+2404
+2405def get_cfbd_transfer_portal_data(
+2406        season: int,
+2407        api_key: str = None,
+2408        api_key_dir: str = None,
+2409        return_as_dict: bool = False):
+2410    """
+2411    Get player usage data (A.K.A., the percentages for how often a player touched the ball),
+2412    for a given season, from the CFBD API.
+2413
+2414    Parameters
+2415    ----------
+2416    `season` (int, mandatory):
+2417        Required argument.
+2418        Specifies the season you want CFB transfer portal data from.
+2419        This must be specified, otherwise this package, and by extension
+2420        the CFBD API, will not accept the request to get CFB transfer portal data stats.
+2421    
+2422    `api_key` (str, optional):
+2423        Semi-optional argument. 
+2424        If `api_key` is null, this function will attempt to load a CFBD API key
+2425        from the python environment, or from a file on this computer.
+2426        If `api_key` is not null, this function will automatically assume that the
+2427        inputted `api_key` is a valid CFBD API key.
+2428
+2429    `api_key_dir` (str, optional):
+2430        Optional argument.
+2431        If `api_key` is set to am empty string, this variable is ignored.
+2432        If `api_key_dir` is null, and `api_key` is null, 
+2433        this function will try to find a CFBD API key file in this user's home directory.
+2434        If `api_key_dir` is set to a string, and `api_key` is null,
+2435        this function will assume that `api_key_dir` is a directory, 
+2436        and will try to find a CFBD API key file in that directory.
+2437
+2438    `return_as_dict` (bool, semi-optional):
+2439        Semi-optional argument.
+2440        If you want this function to return the data as a dictionary (read: JSON object), 
+2441        instead of a pandas `DataFrame` object,
+2442        set `return_as_dict` to `True`.
+2443
+2444    Usage
+2445    ----------
+2446    ```
+2447    ```
+2448    Returns
+2449    ----------
+2450    A pandas `DataFrame` object with transfer portal data, 
+2451    or (if `return_as_dict` is set to `True`) 
+2452    a dictionary object with transfer portal data.
+2453
+2454    """
+2455    now = datetime.now()
+2456    url = "https://api.collegefootballdata.com/player/portal"
+2457
+2458    portal_df = pd.DataFrame()
+2459    row_df = pd.DataFrame()
+2460
+2461    if api_key != None:
+2462        real_api_key = api_key
+2463        del api_key
+2464    else:
+2465        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+2466
+2467    if real_api_key == "tigersAreAwsome":
+2468        raise ValueError(
+2469            "You actually need to change `cfbd_key` to your CFBD API key.")
+2470    elif "Bearer " in real_api_key:
+2471        pass
+2472    elif "Bearer" in real_api_key:
+2473        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+2474    else:
+2475        real_api_key = "Bearer " + real_api_key
+2476
+2477    if season == None:
+2478        # This should never happen without user tampering, but if it does,
+2479        # we need to raise an error, because the CFBD API will refuse this call without a valid season.
+2480        raise SystemError(
+2481            "I don't know how, I don't know why, " +
+2482            "but you managed to call this function while `season` was `None` (NULL)," +
+2483            " and the function got to this point in the code." +
+2484            "\nIf you have a GitHub account, " +
+2485            "please raise an issue on this python package's GitHub page:\n" +
+2486            "https://github.com/armstjc/cfbd-json-py/issues"
+2487        )
+2488    elif season > (now.year + 1):
+2489        raise ValueError(f"`season` cannot be greater than {season}.")
+2490    elif season < 2017:
+2491        raise ValueError(f"Transfer portal wasn't really a thing in {season}.")
+2492
+2493    # URL builder
+2494    ########################################################################################################################################################################################################
+2495
+2496    ## required by API
+2497    url += f"?year={season}"
+2498
+2499    headers = {
+2500        'Authorization': f'{real_api_key}',
+2501        'accept': 'application/json'
+2502    }
+2503
+2504
+2505    response = requests.get(url, headers=headers)
+2506
+2507    if response.status_code == 200:
+2508        pass
+2509    elif response.status_code == 401:
+2510        raise ConnectionRefusedError(
+2511            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+2512        )
+2513    else:
+2514        raise ConnectionError(
+2515            f'Could not connect.\nHTTP Status code {response.status_code}'
+2516        )
+2517
+2518    json_data = response.json()
+2519
+2520    if return_as_dict == True:
+2521        return json_data
+2522
+2523    for player in tqdm(json_data):
+2524        row_df = pd.DataFrame({"season":season},index=[0])
+2525        row_df['first_name'] = player['firstName']
+2526        row_df['last_name'] = player['lastName']
+2527        row_df['position'] = player['position']
+2528        row_df['origin_team'] = player['origin']
+2529        row_df['destination_team'] = player['destination']
+2530        row_df['transferDate'] = player['transferDate']
+2531        row_df['player_rating'] = player['rating']
+2532        row_df['player_stars'] = player['stars']
+2533        row_df['player_eligibility'] = player['eligibility']
+2534        portal_df = pd.concat([portal_df,row_df],ignore_index=True)
+2535        
+2536        del row_df
+2537
+2538    return portal_df
 
@@ -171,24 +2619,536 @@

-
10def cfbd_player_search(
-11        search_str: str,
-12        api_key: str = None,
-13        api_key_dir: str = None,
-14        position: str = None,
-15        team: str = None,
-16        season: int = None,
-17        return_as_dict: bool = False):
-18    """
-19
-20    """
-21    raise NotImplementedError(
-22        'This function has yet to be implemented by this version.'
-23    )
+            
 21def cfbd_player_search(
+ 22        search_str: str,
+ 23        api_key: str = None,
+ 24        api_key_dir: str = None,
+ 25        position: str = None,
+ 26        team: str = None,
+ 27        season: int = None,
+ 28        return_as_dict: bool = False):
+ 29    """
+ 30    Given a string, search for players who's 
+ 31    name matches that string in some capacity.
+ 32
+ 33    Parameters
+ 34    ----------
+ 35    `search_str` (int, mandatory):
+ 36        Mandatory argument.
+ 37        This is the name of the player you are trying to find.
+ 38
+ 39    `api_key` (str, optional):
+ 40        Semi-optional argument. 
+ 41        If `api_key` is null, this function will attempt to load a CFBD API key
+ 42        from the python environment, or from a file on this computer.
+ 43        If `api_key` is not null, this function will automatically assume that the
+ 44        inputted `api_key` is a valid CFBD API key.
+ 45
+ 46    `api_key_dir` (str, optional):
+ 47        Optional argument.
+ 48        If `api_key` is set to am empty string, this variable is ignored.
+ 49        If `api_key_dir` is null, and `api_key` is null, 
+ 50        this function will try to find a CFBD API key file in this user's home directory.
+ 51        If `api_key_dir` is set to a string, and `api_key` is null,
+ 52        this function will assume that `api_key_dir` is a directory, 
+ 53        and will try to find a CFBD API key file in that directory.
+ 54
+ 55    `position` (bool, semi-optional):
+ 56        Semi-optional argument.
+ 57        If you only want players from a specific position, 
+ 58        set `position` to the position you want to find players from.
+ 59
+ 60    `team` (bool, semi-optional):
+ 61        Semi-optional argument.
+ 62        If you only want players from a specific team, 
+ 63        set `team` to the name of the team you want to find players from.
+ 64
+ 65    `season` (bool, semi-optional):
+ 66        Semi-optional argument.
+ 67        If you only want players from a specific CFB season, 
+ 68        set `season` to the season you want to find players from.
+ 69
+ 70    `return_as_dict` (bool, semi-optional):
+ 71        Semi-optional argument.
+ 72        If you want this function to return the data as a dictionary (read: JSON object), 
+ 73        instead of a pandas `DataFrame` object,
+ 74        set `return_as_dict` to `True`.
+ 75
+ 76    Usage
+ 77    ----------
+ 78    ```
+ 79    import time
+ 80
+ 81    from cfbd_json_py.players import cfbd_player_search
+ 82
+ 83
+ 84    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+ 85
+ 86    if cfbd_key != "tigersAreAwsome":
+ 87        print("Using the user's API key declared in this script for this example.")
+ 88
+ 89        # Get a list of every known "Joe" in the CFBD API.
+ 90        print("Get a list of every known \"Joe\" in the CFBD API.")
+ 91        json_data = cfbd_player_search(
+ 92            api_key=cfbd_key,
+ 93            search_str="Joe"
+ 94        )
+ 95        print(json_data)
+ 96        time.sleep(5)
+ 97
+ 98        # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".
+ 99        print("Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".")
+100        json_data = cfbd_player_search(
+101            api_key=cfbd_key,
+102            search_str="Joe B"
+103        )
+104        print(json_data)
+105        time.sleep(5)
+106
+107        # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.
+108        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.")
+109        json_data = cfbd_player_search(
+110            api_key=cfbd_key,
+111            search_str="Jim",
+112            position="QB"
+113        )
+114        print(json_data)
+115        time.sleep(5)
+116
+117
+118        # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.
+119        print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.")
+120        json_data = cfbd_player_search(
+121            api_key=cfbd_key,
+122            search_str="A",
+123            team="Cincinnati"
+124        )
+125        print(json_data)
+126        time.sleep(5)
+127
+128
+129        # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.
+130        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.")
+131        json_data = cfbd_player_search(
+132            api_key=cfbd_key,
+133            search_str="Jim",
+134            position="QB"
+135        )
+136        print(json_data)
+137        time.sleep(5)
+138
+139        # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.
+140        print("Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.")
+141        json_data = cfbd_player_search(
+142            api_key=cfbd_key,
+143            search_str="Joe",
+144            season=2020
+145        )
+146        print(json_data)
+147        time.sleep(5)
+148
+149
+150        # You can also tell this function to just return the API call as
+151        # a Dictionary (read: JSON) object.
+152        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+153        json_data = cfbd_player_search(
+154            api_key=cfbd_key,
+155            search_str="Justin F",
+156            season=2020,
+157            return_as_dict=True
+158        )
+159        print(json_data)
+160
+161    else:
+162        # Alternatively, if the CFBD API key exists in this python environment,
+163        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+164        # you could just call these functions directly, without setting the API key
+165        # in the script.
+166        print("Using the user's API key suposedly loaded into this python environment for this example.")
+167
+168        # Get a list of every known "Joe" in the CFBD API.
+169        print("Get a list of every known \"Joe\" in the CFBD API.")
+170        json_data = cfbd_player_search(
+171            search_str="Joe"
+172        )
+173        print(json_data)
+174        time.sleep(5)
+175
+176        # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".
+177        print("Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".")
+178        json_data = cfbd_player_search(
+179            search_str="Joe B"
+180        )
+181        print(json_data)
+182        time.sleep(5)
+183
+184        # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.
+185        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.")
+186        json_data = cfbd_player_search(
+187            search_str="Jim",
+188            position="QB"
+189        )
+190        print(json_data)
+191        time.sleep(5)
+192
+193
+194        # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.
+195        print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.")
+196        json_data = cfbd_player_search(
+197            search_str="A",
+198            team="Cincinnati"
+199        )
+200        print(json_data)
+201        time.sleep(5)
+202
+203
+204        # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.
+205        print("Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.")
+206        json_data = cfbd_player_search(
+207            search_str="Jim",
+208            position="QB"
+209        )
+210        print(json_data)
+211        time.sleep(5)
+212
+213        # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.
+214        print("Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.")
+215        json_data = cfbd_player_search(
+216            search_str="Joe",
+217            season=2020
+218        )
+219        print(json_data)
+220        time.sleep(5)
+221
+222
+223        # You can also tell this function to just return the API call as
+224        # a Dictionary (read: JSON) object.
+225        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+226        json_data = cfbd_player_search(
+227            search_str="Justin F",
+228            season=2020,
+229            return_as_dict=True
+230        )
+231        print(json_data)
+232
+233    ```
+234    Returns
+235    ----------
+236    A pandas `DataFrame` object with a list of players who matched the search string, 
+237    or (if `return_as_dict` is set to `True`) 
+238    a dictionary object with a list of players who matched the search string.
+239
+240    """
+241    now = datetime.now()
+242    players_df = pd.DataFrame()
+243    row_df = pd.DataFrame()
+244    url = "https://api.collegefootballdata.com/player/search"
+245
+246    ########################################################################################################################################################################################################
+247
+248    if api_key != None:
+249        real_api_key = api_key
+250        del api_key
+251    else:
+252        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+253
+254    if real_api_key == "tigersAreAwsome":
+255        raise ValueError(
+256            "You actually need to change `cfbd_key` to your CFBD API key.")
+257    elif "Bearer " in real_api_key:
+258        pass
+259    elif "Bearer" in real_api_key:
+260        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+261    else:
+262        real_api_key = "Bearer " + real_api_key
+263
+264    if season == None:
+265        # Rare, but in this endpoint,
+266        # you don't need to input the season.
+267        pass
+268    elif season > (now.year + 1):
+269        raise ValueError(f"`season` cannot be greater than {season}.")
+270    elif season < 1869:
+271        raise ValueError(f"`season` cannot be less than 1869.")
+272
+273    # URL builder
+274    ########################################################################################################################################################################################################
+275
+276    # Required by API
+277    url += f"?searchTerm={search_str}"
+278
+279    url = url.replace(" ", "%20")  # For sanity reasons with URLs.
+280
+281    if position != None:
+282        url += f"&position={position}"
+283
+284    if team != None:
+285        url += f"&team={team}"
+286
+287    if season != None:
+288        url += f"&year={season}"
+289
+290    headers = {
+291        'Authorization': f'{real_api_key}',
+292        'accept': 'application/json'
+293    }
+294
+295    response = requests.get(url, headers=headers)
+296
+297    if response.status_code == 200:
+298        pass
+299    elif response.status_code == 401:
+300        raise ConnectionRefusedError(
+301            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+302        )
+303    else:
+304        raise ConnectionError(
+305            f'Could not connect.\nHTTP Status code {response.status_code}'
+306        )
+307
+308    json_data = response.json()
+309
+310    if return_as_dict == True:
+311        return json_data
+312
+313    for player in tqdm(json_data):
+314        p_id = player['id']
+315        row_df = pd.DataFrame(
+316            {"player_id": p_id},
+317            index=[0]
+318        )
+319        row_df['team'] = player['team']
+320        row_df['player_full_name'] = player['name']
+321        row_df['player_first_name'] = player['firstName']
+322        row_df['player_last_name'] = player['lastName']
+323        row_df['weight_lbs'] = player['weight']
+324        row_df['height_in'] = player['height']
+325        row_df['jersey'] = player['jersey']
+326        row_df['position'] = player['position']
+327        row_df['hometown'] = player['hometown']
+328        row_df['team_color_primary'] = player['teamColor']
+329        row_df['team_color_secondary'] = player['teamColorSecondary']
+330
+331        players_df = pd.concat([players_df, row_df], ignore_index=True)
+332
+333        del row_df
+334        del p_id
+335
+336    return players_df
 
- +

Given a string, search for players who's +name matches that string in some capacity.

+ +

Parameters

+ +

search_str (int, mandatory): + Mandatory argument. + This is the name of the player you are trying to find.

+ +

api_key (str, optional): + Semi-optional argument. + If api_key is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If api_key is not null, this function will automatically assume that the + inputted api_key is a valid CFBD API key.

+ +

api_key_dir (str, optional): + Optional argument. + If api_key is set to am empty string, this variable is ignored. + If api_key_dir is null, and api_key is null, + this function will try to find a CFBD API key file in this user's home directory. + If api_key_dir is set to a string, and api_key is null, + this function will assume that api_key_dir is a directory, + and will try to find a CFBD API key file in that directory.

+ +

position (bool, semi-optional): + Semi-optional argument. + If you only want players from a specific position, + set position to the position you want to find players from.

+ +

team (bool, semi-optional): + Semi-optional argument. + If you only want players from a specific team, + set team to the name of the team you want to find players from.

+ +

season (bool, semi-optional): + Semi-optional argument. + If you only want players from a specific CFB season, + set season to the season you want to find players from.

+ +

return_as_dict (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas DataFrame object, + set return_as_dict to True.

+ +

Usage

+ +
import time
+
+from cfbd_json_py.players import cfbd_player_search
+
+
+cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+
+if cfbd_key != "tigersAreAwsome":
+    print("Using the user's API key declared in this script for this example.")
+
+    # Get a list of every known "Joe" in the CFBD API.
+    print("Get a list of every known "Joe" in the CFBD API.")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="Joe"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".
+    print("Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="Joe B"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.
+    print("Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="Jim",
+        position="QB"
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.
+    print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="A",
+        team="Cincinnati"
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.
+    print("Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="Jim",
+        position="QB"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.
+    print("Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="Joe",
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = cfbd_player_search(
+        api_key=cfbd_key,
+        search_str="Justin F",
+        season=2020,
+        return_as_dict=True
+    )
+    print(json_data)
+
+else:
+    # Alternatively, if the CFBD API key exists in this python environment,
+    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+    # you could just call these functions directly, without setting the API key
+    # in the script.
+    print("Using the user's API key suposedly loaded into this python environment for this example.")
+
+    # Get a list of every known "Joe" in the CFBD API.
+    print("Get a list of every known "Joe" in the CFBD API.")
+    json_data = cfbd_player_search(
+        search_str="Joe"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".
+    print("Get a list of every known "Joe" in the CFBD API, who's last name starts with "B".")
+    json_data = cfbd_player_search(
+        search_str="Joe B"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.
+    print("Get a list of every known "Jim" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.")
+    json_data = cfbd_player_search(
+        search_str="Jim",
+        position="QB"
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.
+    print("Get a list of every known player of the University of Cincinnati Football Team, that had the letter "A" in their name.")
+    json_data = cfbd_player_search(
+        search_str="A",
+        team="Cincinnati"
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.
+    print("Get a list of every known "Jim" in the CFBD API, who happened to play QB at some point in their career.")
+    json_data = cfbd_player_search(
+        search_str="Jim",
+        position="QB"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.
+    print("Get a list of every known "Joe" in the CFBD API, who happened to play in the 2020 CFB sesason.")
+    json_data = cfbd_player_search(
+        search_str="Joe",
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = cfbd_player_search(
+        search_str="Justin F",
+        season=2020,
+        return_as_dict=True
+    )
+    print(json_data)
+
+
+ +

Returns

+ +

A pandas DataFrame object with a list of players who matched the search string, +or (if return_as_dict is set to True) +a dictionary object with a list of players who matched the search string.

+
+
@@ -202,26 +3162,638 @@

-
26def get_cfbd_player_usage(
-27        season: int,
-28        api_key: str = None,
-29        api_key_dir: str = None,
-30        team: str = None,
-31        conference_abv: str = None,
-32        position: str = None,
-33        player_id: int = None,
-34        exclude_garbage_time: bool = False,
-35        return_as_dict: bool = False):
-36    """
-37
-38    """
-39    raise NotImplementedError(
-40        'This function has yet to be implemented by this version.'
-41    )
+            
339def get_cfbd_player_usage(
+340        season: int,
+341        api_key: str = None,
+342        api_key_dir: str = None,
+343        team: str = None,
+344        conference_abv: str = None,
+345        position: str = None,
+346        player_id: int = None,
+347        exclude_garbage_time: bool = False,
+348        return_as_dict: bool = False):
+349    """
+350    Get player usage data (A.K.A., the percentages for how often a player touched the ball),
+351    for a given season, at the season level, from the CFBD API.
+352
+353    Parameters
+354    ----------
+355    `season` (int, optional):
+356        Mandatory argument.
+357        Specifies the season you want player usage data from.
+358        You MUST set `season` or `team` to a non-null value for 
+359        this function to work. If you don't, a `ValueError()` 
+360        will be raised.
+361
+362    `api_key` (str, optional):
+363        Semi-optional argument. 
+364        If `api_key` is null, this function will attempt to load a CFBD API key
+365        from the python environment, or from a file on this computer.
+366        If `api_key` is not null, this function will automatically assume that the
+367        inputted `api_key` is a valid CFBD API key.
+368
+369    `api_key_dir` (str, optional):
+370        Optional argument.
+371        If `api_key` is set to am empty string, this variable is ignored.
+372        If `api_key_dir` is null, and `api_key` is null, 
+373        this function will try to find a CFBD API key file in this user's home directory.
+374        If `api_key_dir` is set to a string, and `api_key` is null,
+375        this function will assume that `api_key_dir` is a directory, 
+376        and will try to find a CFBD API key file in that directory.
+377
+378    `team` (str, optional):
+379        Semi-ptional argument.
+380        If you only want player usage data for a specific team,
+381        set `team` to the name of the team you want player usage data from.
+382        You MUST set `season` or `team` to a non-null value for 
+383        this function to work. If you don't, a `ValueError()` 
+384        will be raised.
+385
+386    `position` (str, optional):
+387        Semi-Optional argument.
+388        If you only want player usage data 
+389        for players who played a specific position, 
+390        set `position` to that position's abbreviation. 
+391        A list of CFBD API positions can be found in the `position_abbreviation` column from 
+392        the pandas DataFrame that is returned by calling `cfbd_json_py.draft.get_cfbd_nfl_positions()`.
+393
+394    `conference_abv` (str, optional):
+395        Optional argument.
+396        If you only want player usage data from games 
+397        involving teams from a specific confrence, 
+398        set `conference_abv` to the abbreviation 
+399        of the conference you want player usage data from.
+400        For a list of confrences, 
+401        use the `cfbd_json_py.conferences.get_cfbd_conference_info()`
+402        function.
+403
+404    `player_id` (int, optional):
+405        Optional argument.
+406        If you only want player usage data for a specific player ID, 
+407        set this variable to the player ID of the player you want player usage data from. 
+408
+409    `exclude_garbage_time` (bool, optional):
+410        Optional argument.
+411        If you want to filter out plays where the result of the game is largely decided,
+412        set `exclude_garbage_time = True`.
+413        Default behavior is that this variable is set to 
+414        `False` when this function is called.
+415
+416    `return_as_dict` (bool, semi-optional):
+417        Semi-optional argument.
+418        If you want this function to return the data as a dictionary (read: JSON object), 
+419        instead of a pandas `DataFrame` object,
+420        set `return_as_dict` to `True`.
+421
+422    Usage
+423    ----------
+424    ```
+425    import time
+426
+427    from cfbd_json_py.players import get_cfbd_player_usage
+428
+429
+430    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+431
+432    if cfbd_key != "tigersAreAwsome":
+433        print("Using the user's API key declared in this script for this example.")
+434
+435        # Get player usage data from the 2020 CFB season.
+436        print("Get player usage data from the 2020 CFB season.")
+437        json_data = get_cfbd_player_usage(
+438            api_key=cfbd_key,
+439            season=2020
+440        )
+441        print(json_data)
+442        time.sleep(5)
+443
+444        # Get player usage data for the 
+445        # University of Cincinnati Bearcats Football Team, 
+446        # during the 2020 CFB season.
+447        print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.")
+448        json_data = get_cfbd_player_usage(
+449            api_key=cfbd_key,
+450            season=2020,
+451            team="Cincinnati"
+452        )
+453        print(json_data)
+454        time.sleep(5)
+455
+456        # Get player usage data from players who 
+457        # primarily played running back (RB) in the 2020 CFB season.
+458        print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.")
+459        json_data = get_cfbd_player_usage(
+460            api_key=cfbd_key,
+461            season=2020,
+462            position="RB"
+463        )
+464        print(json_data)
+465        time.sleep(5)
+466
+467        # Get player usage data from players who played on 
+468        # Big 10 Confrence (B1G) teams during the 2020 CFB Season.
+469        print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.")
+470        json_data = get_cfbd_player_usage(
+471            api_key=cfbd_key,
+472            season=2020,
+473            conference_abv="B1G"
+474        )
+475        print(json_data)
+476        time.sleep(5)
+477
+478        # Get player usage data from 
+479        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+480        # during the 2019 CFB season.
+481        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+482        json_data = get_cfbd_player_usage(
+483            api_key=cfbd_key,
+484            season=2019,
+485            player_id=3915511
+486        )
+487        print(json_data)
+488        time.sleep(5)
+489
+490        # Get player usage data from 
+491        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+492        # during the 2019 CFB season, 
+493        # but filter out plays that occured in garbage time.
+494        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+495        json_data = get_cfbd_player_usage(
+496            api_key=cfbd_key,
+497            season=2019,
+498            player_id=3915511,
+499            exclude_garbage_time=True
+500        )
+501        print(json_data)
+502        time.sleep(5)
+503
+504        # You can also tell this function to just return the API call as
+505        # a Dictionary (read: JSON) object.
+506        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+507        json_data = get_cfbd_player_usage(
+508            api_key=cfbd_key,
+509            season=2020,
+510            team="LSU",
+511            return_as_dict=True
+512        )
+513        print(json_data)
+514
+515    else:
+516        # Alternatively, if the CFBD API key exists in this python environment,
+517        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+518        # you could just call these functions directly, without setting the API key
+519        # in the script.
+520        print("Using the user's API key suposedly loaded into this python environment for this example.")
+521
+522        # Get player usage data from the 2020 CFB season.
+523        print("Get player usage data from the 2020 CFB season.")
+524        json_data = get_cfbd_player_usage(
+525            season=2020
+526        )
+527        print(json_data)
+528        time.sleep(5)
+529
+530        # Get player usage data for the 
+531        # University of Cincinnati Bearcats Football Team, 
+532        # during the 2020 CFB season.
+533        print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.")
+534        json_data = get_cfbd_player_usage(
+535            season=2020,
+536            team="Cincinnati"
+537        )
+538        print(json_data)
+539        time.sleep(5)
+540
+541        # Get player usage data from players who 
+542        # primarily played running back (RB) in the 2020 CFB season.
+543        print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.")
+544        json_data = get_cfbd_player_usage(
+545            season=2020,
+546            position="RB"
+547        )
+548        print(json_data)
+549        time.sleep(5)
+550
+551        # Get player usage data from players who played on 
+552        # Big 10 Confrence (B1G) teams during the 2020 CFB Season.
+553        print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.")
+554        json_data = get_cfbd_player_usage(
+555            season=2020,
+556            conference_abv="B1G"
+557        )
+558        print(json_data)
+559        time.sleep(5)
+560
+561        # Get player usage data from 
+562        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+563        # during the 2019 CFB season.
+564        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+565        json_data = get_cfbd_player_usage(
+566            season=2019,
+567            player_id=3915511
+568        )
+569        print(json_data)
+570        time.sleep(5)
+571
+572        # Get player usage data from 
+573        # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+574        # during the 2019 CFB season, 
+575        # but filter out plays that occured in garbage time.
+576        print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+577        json_data = get_cfbd_player_usage(
+578            season=2019,
+579            player_id=3915511,
+580            exclude_garbage_time=True
+581        )
+582        print(json_data)
+583        time.sleep(5)
+584
+585        # You can also tell this function to just return the API call as
+586        # a Dictionary (read: JSON) object.
+587        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+588        json_data = get_cfbd_player_usage(
+589            season=2020,
+590            team="LSU",
+591            return_as_dict=True
+592        )
+593        print(json_data)
+594
+595
+596    ```
+597    Returns
+598    ----------
+599    A pandas `DataFrame` object with player usage data, 
+600    or (if `return_as_dict` is set to `True`) 
+601    a dictionary object with player usage data.
+602
+603    """
+604
+605    now = datetime.now()
+606    players_df = pd.DataFrame()
+607    row_df = pd.DataFrame()
+608    url = "https://api.collegefootballdata.com/player/usage"
+609
+610    ########################################################################################################################################################################################################
+611
+612    if api_key != None:
+613        real_api_key = api_key
+614        del api_key
+615    else:
+616        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+617
+618    if real_api_key == "tigersAreAwsome":
+619        raise ValueError(
+620            "You actually need to change `cfbd_key` to your CFBD API key.")
+621    elif "Bearer " in real_api_key:
+622        pass
+623    elif "Bearer" in real_api_key:
+624        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+625    else:
+626        real_api_key = "Bearer " + real_api_key
+627
+628    if season == None:
+629        # This should never happen without user tampering, but if it does,
+630        # we need to raise an error, because the CFBD API will refuse this call without a valid season.
+631        raise SystemError(
+632            "I don't know how, I don't know why, but you managed to call this function while `season` was `None` (NULL)," +
+633            " and the function got to this point in the code." +
+634            "\nIf you have a GitHub account, please raise an issue on this python package's GitHub page:\n" +
+635            "https://github.com/armstjc/cfbd-json-py/issues"
+636        )
+637    elif season > (now.year + 1):
+638        raise ValueError(f"`season` cannot be greater than {season}.")
+639    elif season < 1869:
+640        raise ValueError(f"`season` cannot be less than 1869.")
+641
+642    gt_str = ""
+643    if exclude_garbage_time == True:
+644        gt_str = "true"
+645    elif exclude_garbage_time == False:
+646        gt_str = "false"
+647
+648    # URL builder
+649    ########################################################################################################################################################################################################
+650
+651    url += f"?year={season}"
+652
+653    if team != None:
+654        url += f"&team={team}"
+655
+656    if conference_abv != None:
+657        url += f"&conference={conference_abv}"
+658
+659    if position != None:
+660        url += f"&position={position}"
+661
+662    if player_id != None:
+663        url += f"&playerId={player_id}"
+664        print()
+665    if exclude_garbage_time != None:
+666        url += f"&excludeGarbageTime={gt_str}"
+667
+668    headers = {
+669        'Authorization': f'{real_api_key}',
+670        'accept': 'application/json'
+671    }
+672
+673    response = requests.get(url, headers=headers)
+674
+675    if response.status_code == 200:
+676        pass
+677    elif response.status_code == 401:
+678        raise ConnectionRefusedError(
+679            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+680        )
+681    else:
+682        raise ConnectionError(
+683            f'Could not connect.\nHTTP Status code {response.status_code}'
+684        )
+685
+686    json_data = response.json()
+687
+688    if return_as_dict == True:
+689        return json_data
+690
+691    for player in tqdm(json_data):
+692        row_df = pd.DataFrame(
+693            {"season": season},
+694            index=[0]
+695        )
+696        row_df['player_id'] = player['id']
+697        row_df['player_name'] = player['name']
+698        row_df['player_position'] = player['position']
+699        row_df['team'] = player['team']
+700        row_df['conference'] = player['conference']
+701        row_df['player_usage_overall'] = player['usage']['overall']
+702        row_df['player_usage_passing'] = player['usage']['pass']
+703        row_df['player_usage_rushing'] = player['usage']['rush']
+704        row_df['player_usage_1st_downs'] = player['usage']['firstDown']
+705        row_df['player_usage_2nd_downs'] = player['usage']['secondDown']
+706        row_df['player_usage_3rd_downs'] = player['usage']['thirdDown']
+707        row_df['player_usage_standard_downs'] = player['usage']['standardDowns']
+708        row_df['player_usage_pasing_downs'] = player['usage']['passingDowns']
+709
+710        players_df = pd.concat([players_df, row_df], ignore_index=True)
+711        del row_df
+712
+713    return players_df
 
- +

Get player usage data (A.K.A., the percentages for how often a player touched the ball), +for a given season, at the season level, from the CFBD API.

+ +

Parameters

+ +

season (int, optional): + Mandatory argument. + Specifies the season you want player usage data from. + You MUST set season or team to a non-null value for + this function to work. If you don't, a ValueError() + will be raised.

+ +

api_key (str, optional): + Semi-optional argument. + If api_key is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If api_key is not null, this function will automatically assume that the + inputted api_key is a valid CFBD API key.

+ +

api_key_dir (str, optional): + Optional argument. + If api_key is set to am empty string, this variable is ignored. + If api_key_dir is null, and api_key is null, + this function will try to find a CFBD API key file in this user's home directory. + If api_key_dir is set to a string, and api_key is null, + this function will assume that api_key_dir is a directory, + and will try to find a CFBD API key file in that directory.

+ +

team (str, optional): + Semi-ptional argument. + If you only want player usage data for a specific team, + set team to the name of the team you want player usage data from. + You MUST set season or team to a non-null value for + this function to work. If you don't, a ValueError() + will be raised.

+ +

position (str, optional): + Semi-Optional argument. + If you only want player usage data + for players who played a specific position, + set position to that position's abbreviation. + A list of CFBD API positions can be found in the position_abbreviation column from + the pandas DataFrame that is returned by calling cfbd_json_py.draft.get_cfbd_nfl_positions().

+ +

conference_abv (str, optional): + Optional argument. + If you only want player usage data from games + involving teams from a specific confrence, + set conference_abv to the abbreviation + of the conference you want player usage data from. + For a list of confrences, + use the cfbd_json_py.conferences.get_cfbd_conference_info() + function.

+ +

player_id (int, optional): + Optional argument. + If you only want player usage data for a specific player ID, + set this variable to the player ID of the player you want player usage data from.

+ +

exclude_garbage_time (bool, optional): + Optional argument. + If you want to filter out plays where the result of the game is largely decided, + set exclude_garbage_time = True. + Default behavior is that this variable is set to + False when this function is called.

+ +

return_as_dict (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas DataFrame object, + set return_as_dict to True.

+ +

Usage

+ +
import time
+
+from cfbd_json_py.players import get_cfbd_player_usage
+
+
+cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+
+if cfbd_key != "tigersAreAwsome":
+    print("Using the user's API key declared in this script for this example.")
+
+    # Get player usage data from the 2020 CFB season.
+    print("Get player usage data from the 2020 CFB season.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data for the 
+    # University of Cincinnati Bearcats Football Team, 
+    # during the 2020 CFB season.
+    print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2020,
+        team="Cincinnati"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from players who 
+    # primarily played running back (RB) in the 2020 CFB season.
+    print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2020,
+        position="RB"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from players who played on 
+    # Big 10 Confrence (B1G) teams during the 2020 CFB Season.
+    print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2020,
+        conference_abv="B1G"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from 
+    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+    # during the 2019 CFB season.
+    print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2019,
+        player_id=3915511
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from 
+    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+    # during the 2019 CFB season, 
+    # but filter out plays that occured in garbage time.
+    print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2019,
+        player_id=3915511,
+        exclude_garbage_time=True
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = get_cfbd_player_usage(
+        api_key=cfbd_key,
+        season=2020,
+        team="LSU",
+        return_as_dict=True
+    )
+    print(json_data)
+
+else:
+    # Alternatively, if the CFBD API key exists in this python environment,
+    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+    # you could just call these functions directly, without setting the API key
+    # in the script.
+    print("Using the user's API key suposedly loaded into this python environment for this example.")
+
+    # Get player usage data from the 2020 CFB season.
+    print("Get player usage data from the 2020 CFB season.")
+    json_data = get_cfbd_player_usage(
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data for the 
+    # University of Cincinnati Bearcats Football Team, 
+    # during the 2020 CFB season.
+    print("Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.")
+    json_data = get_cfbd_player_usage(
+        season=2020,
+        team="Cincinnati"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from players who 
+    # primarily played running back (RB) in the 2020 CFB season.
+    print("Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.")
+    json_data = get_cfbd_player_usage(
+        season=2020,
+        position="RB"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from players who played on 
+    # Big 10 Confrence (B1G) teams during the 2020 CFB Season.
+    print("Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.")
+    json_data = get_cfbd_player_usage(
+        season=2020,
+        conference_abv="B1G"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from 
+    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+    # during the 2019 CFB season.
+    print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+    json_data = get_cfbd_player_usage(
+        season=2019,
+        player_id=3915511
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player usage data from 
+    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), 
+    # during the 2019 CFB season, 
+    # but filter out plays that occured in garbage time.
+    print("Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.")
+    json_data = get_cfbd_player_usage(
+        season=2019,
+        player_id=3915511,
+        exclude_garbage_time=True
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = get_cfbd_player_usage(
+        season=2020,
+        team="LSU",
+        return_as_dict=True
+    )
+    print(json_data)
+
+
+
+ +

Returns

+ +

A pandas DataFrame object with player usage data, +or (if return_as_dict is set to True) +a dictionary object with player usage data.

+
+
@@ -229,30 +3801,527 @@

def - get_cfbd_returning_production( season: int, api_key: str = None, api_key_dir: str = None, team: str = None, conference_abv: str = None, return_as_dict: bool = False): + get_cfbd_returning_production( api_key: str = None, api_key_dir: str = None, season: int = None, team: str = None, conference_abv: str = None, return_as_dict: bool = False):
-
44def get_cfbd_returning_production(
-45        season: int,
-46        api_key: str = None,
-47        api_key_dir: str = None,
-48        team: str = None,
-49        conference_abv: str = None,
-50
-51        return_as_dict: bool = False):
-52    """
-53
-54    """
-55    raise NotImplementedError(
-56        'This function has yet to be implemented by this version.'
-57    )
+            
 716def get_cfbd_returning_production(
+ 717        api_key: str = None,
+ 718        api_key_dir: str = None,
+ 719        season: int = None,
+ 720        team: str = None,
+ 721        # `season` or `team` must be specified.
+ 722        conference_abv: str = None,
+ 723        return_as_dict: bool = False):
+ 724    """
+ 725    Get data from the CFBD API 
+ 726    on how much returning production a team has going into a CFB season.
+ 727
+ 728    Parameters
+ 729    ----------
+ 730
+ 731    `api_key` (str, optional):
+ 732        Semi-optional argument. 
+ 733        If `api_key` is null, this function will attempt to load a CFBD API key
+ 734        from the python environment, or from a file on this computer.
+ 735        If `api_key` is not null, this function will automatically assume that the
+ 736        inputted `api_key` is a valid CFBD API key.
+ 737
+ 738    `api_key_dir` (str, optional):
+ 739        Optional argument.
+ 740        If `api_key` is set to am empty string, this variable is ignored.
+ 741        If `api_key_dir` is null, and `api_key` is null, 
+ 742        this function will try to find a CFBD API key file in this user's home directory.
+ 743        If `api_key_dir` is set to a string, and `api_key` is null,
+ 744        this function will assume that `api_key_dir` is a directory, 
+ 745        and will try to find a CFBD API key file in that directory.
+ 746
+ 747    `season` (int, optional):
+ 748        Semi-optional argument. 
+ 749        Specifies the season you want team PPA data from.
+ 750        You MUST set `season` or `team` to a non-null value for 
+ 751        this function to work. If you don't, a `ValueError()` 
+ 752        will be raised.
+ 753
+ 754    `team` (str, optional):
+ 755        Semi-ptional argument.
+ 756        If you only want team PPA data for a specific team,
+ 757        set `team` to the name of the team you want team PPA data from.
+ 758        You MUST set `season` or `team` to a non-null value for 
+ 759        this function to work. If you don't, a `ValueError()` 
+ 760        will be raised.
+ 761
+ 762    `conference_abv` (str, optional):
+ 763        Optional argument.
+ 764        If you only want team PPA data from games 
+ 765        involving teams from a specific confrence, 
+ 766        set `conference_abv` to the abbreviation 
+ 767        of the conference you want team PPA data from.
+ 768        For a list of confrences, 
+ 769        use the `cfbd_json_py.conferences.get_cfbd_conference_info()`
+ 770        function.
+ 771
+ 772    `return_as_dict` (bool, semi-optional):
+ 773        Semi-optional argument.
+ 774        If you want this function to return the data as a dictionary (read: JSON object), 
+ 775        instead of a pandas `DataFrame` object,
+ 776        set `return_as_dict` to `True`.
+ 777
+ 778    Usage
+ 779    ----------
+ 780    ```
+ 781    import time
+ 782
+ 783    from cfbd_json_py.players import get_cfbd_returning_production
+ 784
+ 785
+ 786    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+ 787
+ 788    if cfbd_key != "tigersAreAwsome":
+ 789        print("Using the user's API key declared in this script for this example.")
+ 790
+ 791        # Get returning production for teams who competed in the 2020 CFB season.
+ 792        print("Get returning production for teams who competed in the 2020 CFB season.")
+ 793        json_data = get_cfbd_returning_production(
+ 794            api_key=cfbd_key,
+ 795            season=2020
+ 796        )
+ 797        print(json_data)
+ 798        time.sleep(5)
+ 799
+ 800        # Get historical returning production for the Ohio Bobcats Football Team.
+ 801        print("Get historical returning production for the Ohio Bobcats Football Team.")
+ 802        json_data = get_cfbd_returning_production(
+ 803            api_key=cfbd_key,
+ 804            team="Ohio"
+ 805        )
+ 806        print(json_data)
+ 807        time.sleep(5)
+ 808
+ 809        # Get returning production for the 2019 LSU Tigers.
+ 810        print("Get returning production for the 2019 LSU Tigers.")
+ 811        json_data = get_cfbd_returning_production(
+ 812            api_key=cfbd_key,
+ 813            season=2019,
+ 814            team="LSU"
+ 815        )
+ 816        print(json_data)
+ 817        time.sleep(5)
+ 818
+ 819        # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.
+ 820        print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.")
+ 821        json_data = get_cfbd_returning_production(
+ 822            api_key=cfbd_key,
+ 823            team="Maryland",
+ 824            conference_abv="B1G"
+ 825        )
+ 826        print(json_data)
+ 827        time.sleep(5)
+ 828
+ 829        # Get returning production .
+ 830        print("Get returning production for the 2019 LSU Tigers.")
+ 831        json_data = get_cfbd_returning_production(
+ 832            api_key=cfbd_key,
+ 833            season=2019,
+ 834            team="LSU"
+ 835        )
+ 836        print(json_data)
+ 837        time.sleep(5)
+ 838
+ 839        # You can also tell this function to just return the API call as
+ 840        # a Dictionary (read: JSON) object.
+ 841        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 842        json_data = get_cfbd_returning_production(
+ 843            api_key=cfbd_key,
+ 844            season=2020,
+ 845            team="LSU",
+ 846            return_as_dict=True
+ 847        )
+ 848        print(json_data)
+ 849
+ 850    else:
+ 851        # Alternatively, if the CFBD API key exists in this python environment,
+ 852        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+ 853        # you could just call these functions directly, without setting the API key
+ 854        # in the script.
+ 855        print("Using the user's API key suposedly loaded into this python environment for this example.")
+ 856
+ 857        # Get returning production for teams who competed in the 2020 CFB season.
+ 858        print("Get returning production for teams who competed in the 2020 CFB season.")
+ 859        json_data = get_cfbd_returning_production(
+ 860            season=2020
+ 861        )
+ 862        print(json_data)
+ 863        time.sleep(5)
+ 864
+ 865        # Get historical returning production for the Ohio Bobcats Football Team.
+ 866        print("Get historical returning production for the Ohio Bobcats Football Team.")
+ 867        json_data = get_cfbd_returning_production(
+ 868            team="Ohio"
+ 869        )
+ 870        print(json_data)
+ 871        time.sleep(5)
+ 872
+ 873        # Get returning production for the 2019 LSU Tigers.
+ 874        print("Get returning production for the 2019 LSU Tigers.")
+ 875        json_data = get_cfbd_returning_production(
+ 876            season=2019,
+ 877            team="LSU"
+ 878        )
+ 879        print(json_data)
+ 880        time.sleep(5)
+ 881
+ 882        # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.
+ 883        print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.")
+ 884        json_data = get_cfbd_returning_production(
+ 885            team="Maryland",
+ 886            conference_abv="B1G"
+ 887        )
+ 888        print(json_data)
+ 889        time.sleep(5)
+ 890
+ 891        # Get returning production .
+ 892        print("Get returning production for the 2019 LSU Tigers.")
+ 893        json_data = get_cfbd_returning_production(
+ 894            season=2019,
+ 895            team="LSU"
+ 896        )
+ 897        print(json_data)
+ 898        time.sleep(5)
+ 899
+ 900        # You can also tell this function to just return the API call as
+ 901        # a Dictionary (read: JSON) object.
+ 902        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+ 903        json_data = get_cfbd_returning_production(
+ 904            season=2020,
+ 905            team="LSU",
+ 906            return_as_dict=True
+ 907        )
+ 908        print(json_data)
+ 909
+ 910    ```
+ 911    Returns
+ 912    ----------
+ 913    A pandas `DataFrame` object with returning production data, 
+ 914    or (if `return_as_dict` is set to `True`) 
+ 915    a dictionary object with returning production data.
+ 916
+ 917    """
+ 918    now = datetime.now()
+ 919    team_df = pd.DataFrame()
+ 920    row_df = pd.DataFrame()
+ 921    url = "https://api.collegefootballdata.com/player/returning"
+ 922
+ 923    ########################################################################################################################################################################################################
+ 924
+ 925    if api_key != None:
+ 926        real_api_key = api_key
+ 927        del api_key
+ 928    else:
+ 929        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+ 930
+ 931    if real_api_key == "tigersAreAwsome":
+ 932        raise ValueError(
+ 933            "You actually need to change `cfbd_key` to your CFBD API key.")
+ 934    elif "Bearer " in real_api_key:
+ 935        pass
+ 936    elif "Bearer" in real_api_key:
+ 937        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+ 938    else:
+ 939        real_api_key = "Bearer " + real_api_key
+ 940
+ 941    if season == None and team == None:
+ 942        raise ValueError(
+ 943            "To use this function, `season` and/or `team` must be set to a " +
+ 944            "non-null variable."
+ 945        )
+ 946
+ 947    if season == None:
+ 948        # Rare, but in this endpoint,
+ 949        # you don't need to input the season.
+ 950        pass
+ 951    elif season > (now.year + 1):
+ 952        raise ValueError(f"`season` cannot be greater than {season}.")
+ 953    elif season < 1869:
+ 954        raise ValueError(f"`season` cannot be less than 1869.")
+ 955
+ 956    # URL Builder
+ 957    ########################################################################################################################################################################################################
+ 958    url_elements = 0
+ 959
+ 960    if season != None and url_elements == 0:
+ 961        url += f"?year={season}"
+ 962        url_elements += 1
+ 963    elif season != None:
+ 964        url += f"&year={season}"
+ 965        url_elements += 1
+ 966
+ 967    if team != None and url_elements == 0:
+ 968        url += f"?team={team}"
+ 969        url_elements += 1
+ 970    elif team != None:
+ 971        url += f"&team={team}"
+ 972        url_elements += 1
+ 973
+ 974    if conference_abv != None and url_elements == 0:
+ 975        url += f"?conference={conference_abv}"
+ 976        url_elements += 1
+ 977    elif conference_abv != None:
+ 978        url += f"&conference={conference_abv}"
+ 979        url_elements += 1
+ 980
+ 981    headers = {
+ 982        'Authorization': f'{real_api_key}',
+ 983        'accept': 'application/json'
+ 984    }
+ 985
+ 986    response = requests.get(url, headers=headers)
+ 987
+ 988    if response.status_code == 200:
+ 989        pass
+ 990    elif response.status_code == 401:
+ 991        raise ConnectionRefusedError(
+ 992            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+ 993        )
+ 994    else:
+ 995        raise ConnectionError(
+ 996            f'Could not connect.\nHTTP Status code {response.status_code}'
+ 997        )
+ 998
+ 999    json_data = response.json()
+1000
+1001    if return_as_dict == True:
+1002        return json_data
+1003
+1004    for team in tqdm(json_data):
+1005        t_season = team['season']
+1006        t_conference = team['conference']
+1007        t_name = team['team']
+1008
+1009        row_df = pd.DataFrame(
+1010            {
+1011                "season": t_season,
+1012                "team_name": t_name,
+1013                "team_conference": t_conference
+1014            },
+1015            index=[0]
+1016        )
+1017        row_df['total_ppa'] = team['totalPPA']
+1018        row_df['total_ppa_passing'] = team['totalPassingPPA']
+1019        row_df['total_ppa_rushing'] = team['totalRushingPPA']
+1020        row_df['total_ppa_receiving'] = team['totalReceivingPPA']
+1021        row_df['percent_ppa'] = team['percentPPA']
+1022        row_df['percent_ppa_passing'] = team['percentPassingPPA']
+1023        row_df['percent_ppa_rushing'] = team['percentRushingPPA']
+1024        row_df['percent_ppa_receiving'] = team['percentReceivingPPA']
+1025        row_df['usage'] = team['usage']
+1026        row_df['passing_usage'] = team['passingUsage']
+1027        row_df['rushing_usage'] = team['rushingUsage']
+1028        row_df['receiving_usage'] = team['receivingUsage']
+1029
+1030        team_df = pd.concat([team_df, row_df], ignore_index=True)
+1031
+1032        del row_df
+1033        del t_season, t_conference, t_name
+1034
+1035    return team_df
 
- +

Get data from the CFBD API +on how much returning production a team has going into a CFB season.

+ +

Parameters

+ +

api_key (str, optional): + Semi-optional argument. + If api_key is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If api_key is not null, this function will automatically assume that the + inputted api_key is a valid CFBD API key.

+ +

api_key_dir (str, optional): + Optional argument. + If api_key is set to am empty string, this variable is ignored. + If api_key_dir is null, and api_key is null, + this function will try to find a CFBD API key file in this user's home directory. + If api_key_dir is set to a string, and api_key is null, + this function will assume that api_key_dir is a directory, + and will try to find a CFBD API key file in that directory.

+ +

season (int, optional): + Semi-optional argument. + Specifies the season you want team PPA data from. + You MUST set season or team to a non-null value for + this function to work. If you don't, a ValueError() + will be raised.

+ +

team (str, optional): + Semi-ptional argument. + If you only want team PPA data for a specific team, + set team to the name of the team you want team PPA data from. + You MUST set season or team to a non-null value for + this function to work. If you don't, a ValueError() + will be raised.

+ +

conference_abv (str, optional): + Optional argument. + If you only want team PPA data from games + involving teams from a specific confrence, + set conference_abv to the abbreviation + of the conference you want team PPA data from. + For a list of confrences, + use the cfbd_json_py.conferences.get_cfbd_conference_info() + function.

+ +

return_as_dict (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas DataFrame object, + set return_as_dict to True.

+ +

Usage

+ +
import time
+
+from cfbd_json_py.players import get_cfbd_returning_production
+
+
+cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+
+if cfbd_key != "tigersAreAwsome":
+    print("Using the user's API key declared in this script for this example.")
+
+    # Get returning production for teams who competed in the 2020 CFB season.
+    print("Get returning production for teams who competed in the 2020 CFB season.")
+    json_data = get_cfbd_returning_production(
+        api_key=cfbd_key,
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get historical returning production for the Ohio Bobcats Football Team.
+    print("Get historical returning production for the Ohio Bobcats Football Team.")
+    json_data = get_cfbd_returning_production(
+        api_key=cfbd_key,
+        team="Ohio"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get returning production for the 2019 LSU Tigers.
+    print("Get returning production for the 2019 LSU Tigers.")
+    json_data = get_cfbd_returning_production(
+        api_key=cfbd_key,
+        season=2019,
+        team="LSU"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.
+    print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.")
+    json_data = get_cfbd_returning_production(
+        api_key=cfbd_key,
+        team="Maryland",
+        conference_abv="B1G"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get returning production .
+    print("Get returning production for the 2019 LSU Tigers.")
+    json_data = get_cfbd_returning_production(
+        api_key=cfbd_key,
+        season=2019,
+        team="LSU"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = get_cfbd_returning_production(
+        api_key=cfbd_key,
+        season=2020,
+        team="LSU",
+        return_as_dict=True
+    )
+    print(json_data)
+
+else:
+    # Alternatively, if the CFBD API key exists in this python environment,
+    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+    # you could just call these functions directly, without setting the API key
+    # in the script.
+    print("Using the user's API key suposedly loaded into this python environment for this example.")
+
+    # Get returning production for teams who competed in the 2020 CFB season.
+    print("Get returning production for teams who competed in the 2020 CFB season.")
+    json_data = get_cfbd_returning_production(
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get historical returning production for the Ohio Bobcats Football Team.
+    print("Get historical returning production for the Ohio Bobcats Football Team.")
+    json_data = get_cfbd_returning_production(
+        team="Ohio"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get returning production for the 2019 LSU Tigers.
+    print("Get returning production for the 2019 LSU Tigers.")
+    json_data = get_cfbd_returning_production(
+        season=2019,
+        team="LSU"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.
+    print("Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.")
+    json_data = get_cfbd_returning_production(
+        team="Maryland",
+        conference_abv="B1G"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get returning production .
+    print("Get returning production for the 2019 LSU Tigers.")
+    json_data = get_cfbd_returning_production(
+        season=2019,
+        team="LSU"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = get_cfbd_returning_production(
+        season=2020,
+        team="LSU",
+        return_as_dict=True
+    )
+    print(json_data)
+
+
+ +

Returns

+ +

A pandas DataFrame object with returning production data, +or (if return_as_dict is set to True) +a dictionary object with returning production data.

+
+

@@ -260,34 +4329,1665 @@

def - get_cfbd_player_season_stats( season: int, api_key: str = None, api_key_dir: str = None, team: str = None, conference_abv: str = None, start_week: int = None, end_week: int = None, season_type: str = 'regular', stat_category: str = None, return_as_dict: bool = False): + get_cfbd_player_season_stats( season: int, api_key: str = None, api_key_dir: str = None, team: str = None, conference_abv: str = None, start_week: int = None, end_week: int = None, season_type: str = 'both', stat_category: str = None, return_as_dict: bool = False):
-
60def get_cfbd_player_season_stats(
-61        season: int,
-62        api_key: str = None,
-63        api_key_dir: str = None,
-64        team: str = None,
-65        conference_abv: str = None,
-66        start_week: int = None,
-67        end_week: int = None,
-68        season_type: str = 'regular',  # "regular", "postseason", or "both"
-69        stat_category: str = None,
-70
-71        return_as_dict: bool = False):
-72    """
-73
-74    """
-75    raise NotImplementedError(
-76        'This function has yet to be implemented by this version.'
-77    )
+            
1038def get_cfbd_player_season_stats(
+1039        season: int,
+1040        api_key: str = None,
+1041        api_key_dir: str = None,
+1042        team: str = None,
+1043        conference_abv: str = None,
+1044        start_week: int = None,
+1045        end_week: int = None,
+1046        season_type: str = "both",  # "regular", "postseason", or "both"
+1047        stat_category: str = None,
+1048        return_as_dict: bool = False):
+1049    """
+1050    Get player season stats, or the stats of players in a specific timeframe, from the CFBD API.
+1051
+1052    Parameters
+1053    ----------
+1054    `season` (int, mandatory):
+1055        Required argument.
+1056        Specifies the season you want CFB player season stats from.
+1057        This must be specified, otherwise this package, and by extension
+1058        the CFBD API, will not accept the request to get CFB player season stats.
+1059
+1060    `api_key` (str, optional):
+1061        Semi-optional argument. 
+1062        If `api_key` is null, this function will attempt to load a CFBD API key
+1063        from the python environment, or from a file on this computer.
+1064        If `api_key` is not null, this function will automatically assume that the
+1065        inputted `api_key` is a valid CFBD API key.
+1066
+1067    `api_key_dir` (str, optional):
+1068        Optional argument.
+1069        If `api_key` is set to am empty string, this variable is ignored.
+1070        If `api_key_dir` is null, and `api_key` is null, 
+1071        this function will try to find a CFBD API key file in this user's home directory.
+1072        If `api_key_dir` is set to a string, and `api_key` is null,
+1073        this function will assume that `api_key_dir` is a directory, 
+1074        and will try to find a CFBD API key file in that directory.
+1075
+1076    `team` (str, optional):
+1077        Optional argument.
+1078        If you only want CFB player season stats for a team, 
+1079        regardless if they are the home/away team,
+1080        set `team` to the name of the team you want CFB player season stats from.
+1081
+1082    `conference_abv` (str, optional):
+1083        Optional argument.
+1084        If you only want player season stats from games 
+1085        involving teams a specific confrence, 
+1086        set `conference_abv` to the abbreviation 
+1087        of the conference you want stats from.
+1088
+1089    `start_week` (int, semi-optional):
+1090        Optional argument.
+1091        If you only want player stats for a range of weeks, 
+1092        set `start_week` and `end_week` to 
+1093        the range of weeks you want season-level data for.
+1094
+1095    `end_week` (int, semi-optional):
+1096        Optional argument.
+1097        If you only want player stats for a range of weeks, 
+1098        set `start_week` and `end_week` to 
+1099        the range of weeks you want season-level data for.
+1100
+1101    **NOTE**: If the following conditions are `True`, a `ValueError()` 
+1102    will be raised when calling this function:
+1103    - `start_week < 0`
+1104    - `end_week < 0`
+1105    - `start_week != None and end_week == None` (will be changed in a future version)
+1106    - `start_week == None and end_week != None` (will be changed in a future version)
+1107    - `end_week < start_week`
+1108    - `end_week = start_week`
+1109
+1110    `season_type` (str, semi-optional):
+1111        Semi-optional argument.
+1112        By defualt, this will be set to "regular", for the CFB regular season.
+1113        If you want CFB media information for non-regular season games, 
+1114        set `season_type` to "postseason".
+1115        If you want ***both*** regular and postseason stats, set `season_type = "both"`.
+1116        If `season_type` is set to anything but "regular", "postseason",  or "both", 
+1117        a `ValueError()` will be raised.
+1118
+1119    `stat_category` (str, optional):
+1120        Optional argument.
+1121        If only want stats for a specific stat category, 
+1122        set this variable to that category.
+1123
+1124        Valid inputs are:
+1125        - `passing`
+1126        - `rushing`
+1127        - `receiving`
+1128        - `fumbles`
+1129        - `defensive`
+1130        - `interceptions`
+1131        - `punting`
+1132        - `kicking`
+1133        - `kickReturns`
+1134        - `puntReturns`
+1135
+1136    `return_as_dict` (bool, semi-optional):
+1137        Semi-optional argument.
+1138        If you want this function to return the data as a dictionary (read: JSON object), 
+1139        instead of a pandas `DataFrame` object,
+1140        set `return_as_dict` to `True`.
+1141
+1142    Usage
+1143    ----------
+1144    ```
+1145    import time
+1146
+1147    from cfbd_json_py.players import get_cfbd_player_season_stats
+1148
+1149
+1150    cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+1151
+1152    if cfbd_key != "tigersAreAwsome":
+1153        print("Using the user's API key declared in this script for this example.")
+1154
+1155        # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.
+1156        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.")
+1157        json_data = get_cfbd_player_season_stats(
+1158            api_key=cfbd_key,
+1159            season=2020,
+1160            team="Ohio"
+1161        )
+1162        print(json_data)
+1163        time.sleep(5)
+1164
+1165        # Get player season stats for teams who competed in 
+1166        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1167        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1168        json_data = get_cfbd_player_season_stats(
+1169            api_key=cfbd_key,
+1170            season=2020,
+1171            conference_abv="SEC"
+1172        )
+1173        print(json_data)
+1174        time.sleep(5)
+1175
+1176        # Get player season stats for teams who competed in 
+1177        # the Southeastern Confrence (SEC) in the 2023 CFB season,
+1178        # but only between weeks 1 and 5.
+1179        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1180        json_data = get_cfbd_player_season_stats(
+1181            api_key=cfbd_key,
+1182            season=2020,
+1183            conference_abv="SEC",
+1184            start_week=1,
+1185            end_week=5
+1186        )
+1187        print(json_data)
+1188        time.sleep(5)
+1189
+1190
+1191        # Get player season stats for the 2020 CFB season.
+1192        print("Get player season stats for the 2020 CFB season.")
+1193        json_data = get_cfbd_player_season_stats(
+1194            api_key=cfbd_key,
+1195            season=2020
+1196        )
+1197        print(json_data)
+1198        time.sleep(5)
+1199
+1200
+1201        # Get player season stats for 
+1202        # the Ohio Bobcats Football team in the 2022 CFB season, 
+1203        # but only use regular season games when calculating season stats.
+1204        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.")
+1205        json_data = get_cfbd_player_season_stats(
+1206            api_key=cfbd_key,
+1207            season=2022,
+1208            team="Ohio",
+1209            season_type="regular"
+1210        )
+1211        print(json_data)
+1212        time.sleep(5)
+1213
+1214        # Get passing stats for teams who competed in 
+1215        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1216        print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1217        json_data = get_cfbd_player_season_stats(
+1218            api_key=cfbd_key,
+1219            season=2020,
+1220            conference_abv="SEC",
+1221            stat_category="passing"
+1222        )
+1223        print(json_data)
+1224        time.sleep(5)
+1225
+1226        # You can also tell this function to just return the API call as
+1227        # a Dictionary (read: JSON) object.
+1228        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+1229        json_data = get_cfbd_player_season_stats(
+1230            api_key=cfbd_key,
+1231            season=2020,
+1232            team="LSU",
+1233            stat_category="kicking",
+1234            return_as_dict=True
+1235        )
+1236        print(json_data)
+1237
+1238    else:
+1239        # Alternatively, if the CFBD API key exists in this python environment,
+1240        # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+1241        # you could just call these functions directly, without setting the API key
+1242        # in the script.
+1243        print("Using the user's API key suposedly loaded into this python environment for this example.")
+1244
+1245        # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.
+1246        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.")
+1247        json_data = get_cfbd_player_season_stats(
+1248            season=2020,
+1249            team="Ohio"
+1250        )
+1251        print(json_data)
+1252        time.sleep(5)
+1253
+1254        # Get player season stats for teams who competed in 
+1255        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1256        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1257        json_data = get_cfbd_player_season_stats(
+1258            season=2020,
+1259            conference_abv="SEC"
+1260        )
+1261        print(json_data)
+1262        time.sleep(5)
+1263
+1264        # Get player season stats for teams who competed in 
+1265        # the Southeastern Confrence (SEC) in the 2023 CFB season,
+1266        # but only between weeks 1 and 5.
+1267        print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1268        json_data = get_cfbd_player_season_stats(
+1269            season=2020,
+1270            conference_abv="SEC",
+1271            start_week=1,
+1272            end_week=5
+1273        )
+1274        print(json_data)
+1275        time.sleep(5)
+1276
+1277
+1278        # Get player season stats for the 2020 CFB season.
+1279        print("Get player season stats for the 2020 CFB season.")
+1280        json_data = get_cfbd_player_season_stats(
+1281            season=2020
+1282        )
+1283        print(json_data)
+1284        time.sleep(5)
+1285
+1286
+1287        # Get player season stats for 
+1288        # the Ohio Bobcats Football team in the 2022 CFB season, 
+1289        # but only use regular season games when calculating season stats.
+1290        print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.")
+1291        json_data = get_cfbd_player_season_stats(
+1292            season=2022,
+1293            team="Ohio",
+1294            season_type="regular"
+1295        )
+1296        print(json_data)
+1297        time.sleep(5)
+1298
+1299        # Get passing stats for teams who competed in 
+1300        # the Southeastern Confrence (SEC) in the 2023 CFB season.
+1301        print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+1302        json_data = get_cfbd_player_season_stats(
+1303            season=2020,
+1304            conference_abv="SEC",
+1305            stat_category="passing"
+1306        )
+1307        print(json_data)
+1308        time.sleep(5)
+1309
+1310        # You can also tell this function to just return the API call as
+1311        # a Dictionary (read: JSON) object.
+1312        print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+1313        json_data = get_cfbd_player_season_stats(
+1314            season=2020,
+1315            team="LSU",
+1316            stat_category="kicking",
+1317            return_as_dict=True
+1318        )
+1319        print(json_data)
+1320
+1321
+1322    ```
+1323    Returns
+1324    ----------
+1325    A pandas `DataFrame` object with a list of players who matched the search string, 
+1326    or (if `return_as_dict` is set to `True`) 
+1327    a dictionary object with a list of players who matched the search string.
+1328
+1329    """
+1330    
+1331    rebuilt_json = {}
+1332    stat_columns = [
+1333        'season',
+1334        'team_name',
+1335        'team_confrence',
+1336        'player_id',
+1337        'player_name',
+1338        # PASS
+1339        'passing_COMP',
+1340        'passing_ATT',
+1341        'passing_COMP%',
+1342        'passing_YDS',
+1343        'passing_AVG',
+1344        'passing_TD',
+1345        'passing_INT',
+1346        # RUSH
+1347        'rushing_CAR',
+1348        'rushing_YDS',
+1349        'rushing_AVG',
+1350        'rushing_TD',
+1351        'rushing_LONG',
+1352        # REC
+1353        'receiving_REC',
+1354        'receiving_YDS',
+1355        'receiving_AVG',
+1356        'receiving_TD',
+1357        'receiving_LONG',
+1358        # FUM
+1359        'fumbles_FUM',
+1360        'fumbles_LOST',
+1361        'fumbles_REC',
+1362        # DEFENSE
+1363        'defensive_TOT',
+1364        'defensive_SOLO',
+1365        'defensive_TFL',
+1366        'defensive_QB HUR',
+1367        'defensive_SACKS',
+1368        'defensive_PD',
+1369        'defensive_TD',
+1370        # INT
+1371        'interceptions_INT',
+1372        'interceptions_YDS',
+1373        'interceptions_TD',
+1374        # PUNT
+1375        'punting_NO',
+1376        'punting_YDS',
+1377        'punting_AVG',
+1378        'punting_TB',
+1379        'punting_In 20',
+1380        'punting_LONG',
+1381        # KICK
+1382        'kicking_FGM',
+1383        'kicking_FGA',
+1384        'kicking_FG%',
+1385        'kicking_LONG',
+1386        'kicking_XPM',
+1387        'kicking_XPA',
+1388        'kicking_XP%',
+1389        # KR
+1390        'kickReturns_NO',
+1391        'kickReturns_YDS',
+1392        'kickReturns_AVG',
+1393        'kickReturns_TD',
+1394        'kickReturns_LONG',
+1395        # PR
+1396        'puntReturns_NO',
+1397        'puntReturns_YDS',
+1398        'puntReturns_AVG',
+1399        'puntReturns_TD',
+1400        'puntReturns_LONG'
+1401    ]
+1402
+1403    now = datetime.now()
+1404    url = "https://api.collegefootballdata.com/stats/player/season"
+1405
+1406    final_df = pd.DataFrame()
+1407
+1408    if api_key != None:
+1409        real_api_key = api_key
+1410        del api_key
+1411    else:
+1412        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+1413
+1414    if real_api_key == "tigersAreAwsome":
+1415        raise ValueError(
+1416            "You actually need to change `cfbd_key` to your CFBD API key.")
+1417    elif "Bearer " in real_api_key:
+1418        pass
+1419    elif "Bearer" in real_api_key:
+1420        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+1421    else:
+1422        real_api_key = "Bearer " + real_api_key
+1423
+1424    if season == None:
+1425        # This should never happen without user tampering, but if it does,
+1426        # we need to raise an error, because the CFBD API will refuse this call without a valid season.
+1427        raise SystemError(
+1428            "I don't know how, I don't know why, " +
+1429            "but you managed to call this function while `season` was `None` (NULL)," +
+1430            " and the function got to this point in the code." +
+1431            "\nIf you have a GitHub account, " +
+1432            "please raise an issue on this python package's GitHub page:\n" +
+1433            "https://github.com/armstjc/cfbd-json-py/issues"
+1434        )
+1435    elif season > (now.year + 1):
+1436        raise ValueError(f"`season` cannot be greater than {season}.")
+1437    elif season < 1869:
+1438        raise ValueError(f"`season` cannot be less than 1869.")
+1439
+1440    if season_type != "regular" and season_type != "postseason" and season_type != "both":
+1441        raise ValueError(
+1442            "`season_type` must be set to either \"regular\" or " +
+1443            "\"postseason\" for this function to work."
+1444        )
+1445
+1446    filter_by_stat_category = False
+1447
+1448    if stat_category == None:
+1449        pass
+1450    elif stat_category == "passing":
+1451        filter_by_stat_category = True
+1452    elif stat_category == "rushing":
+1453        filter_by_stat_category = True
+1454    elif stat_category == "receiving":
+1455        filter_by_stat_category = True
+1456    elif stat_category == "fumbles":
+1457        filter_by_stat_category = True
+1458    elif stat_category == "passing":
+1459        filter_by_stat_category = True
+1460    elif stat_category == "defensive":
+1461        filter_by_stat_category = True
+1462    elif stat_category == "interceptions":
+1463        filter_by_stat_category = True
+1464    elif stat_category == "punting":
+1465        filter_by_stat_category = True
+1466    elif stat_category == "kicking":
+1467        filter_by_stat_category = True
+1468    elif stat_category == "kickReturns":
+1469        filter_by_stat_category = True
+1470    elif stat_category == "puntReturns":
+1471        filter_by_stat_category = True
+1472    else:
+1473        raise ValueError(
+1474            "Invalid input for `stat_category`." +
+1475            "\nValid inputs are:" +
+1476            """
+1477            - `passing`
+1478            - `rushing`
+1479            - `receiving`
+1480            - `fumbles`
+1481            - `defensive`
+1482            - `interceptions`
+1483            - `punting`
+1484            - `kicking`
+1485            - `kickReturns`
+1486            - `puntReturns`
+1487            """
+1488        )
+1489
+1490    if start_week != None and end_week != None:
+1491        if start_week > end_week:
+1492            raise ValueError(
+1493                "`start_week` cannot be greater than `end_week`."
+1494            )
+1495        elif start_week == end_week:
+1496            raise ValueError(
+1497                "`start_week` cannot be equal to `end_week`." +
+1498                "\n Use `cfbd_json_py.games.get_cfbd_player_game_stats()` instead " +
+1499                "if you want player stats for a specific week in ."
+1500            )
+1501        elif start_week < 0:
+1502            raise ValueError(
+1503                "`start_week` cannot be less than 0."
+1504            )
+1505        elif end_week < 0:
+1506            raise ValueError(
+1507                "`end_week` cannot be less than 0."
+1508            )
+1509    #
+1510    # elif start_week != None and end_week == None:
+1511    #     raise ValueError(
+1512    #         "At this time, if you want to get season stats for a range of weeks " +
+1513    #         "`start_week` and `end_week` must be set to valid integers," +
+1514    #         " and not just `start_week`."
+1515    #     )
+1516    # elif start_week == None and end_week != None:
+1517    #     raise ValueError(
+1518    #         "At this time, if you want to get season stats for a range of weeks " +
+1519    #         "`start_week` and `end_week` must be set to valid integers," +
+1520    #         " and not just `end_week`."
+1521    #     )
+1522
+1523    if filter_by_stat_category == True:
+1524        pass
+1525
+1526    # URL builder
+1527    ########################################################################################################################################################################################################
+1528
+1529    # Required by the API
+1530    url += f"?year={season}"
+1531
+1532    if team != None:
+1533        url += f"&team={team}"
+1534
+1535    if conference_abv != None:
+1536        url += f"&conference={conference_abv}"
+1537
+1538    if season_type != None:
+1539        url += f"&seasonType={season_type}"
+1540
+1541    if stat_category != None:
+1542        url += f"&category={stat_category}"
+1543
+1544    if start_week != None:
+1545        url += f"&startWeek={start_week}"
+1546
+1547    if end_week != None:
+1548        url += f"&endWeek={end_week}"
+1549
+1550    headers = {
+1551        'Authorization': f'{real_api_key}',
+1552        'accept': 'application/json'
+1553    }
+1554
+1555    response = requests.get(url, headers=headers)
+1556
+1557    if response.status_code == 200:
+1558        pass
+1559    elif response.status_code == 401:
+1560        raise ConnectionRefusedError(
+1561            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+1562        )
+1563    else:
+1564        raise ConnectionError(
+1565            f'Could not connect.\nHTTP Status code {response.status_code}'
+1566        )
+1567
+1568    json_data = response.json()
+1569
+1570    if return_as_dict == True:
+1571        return json_data
+1572
+1573    for player in tqdm(json_data):
+1574        player_id = int(player['playerId'])
+1575        player_name = player['player']
+1576        team_name = player['team']
+1577        team_confrence = player['conference']
+1578        s_category = player['category']
+1579        s_type = player['statType']
+1580        s_num = player['stat']
+1581
+1582        if rebuilt_json.get(player_id) == None:
+1583            rebuilt_json[player_id] = {}
+1584
+1585        if s_category == "passing":
+1586            if s_type == "COMPLETIONS":
+1587                rebuilt_json[player_id]['player_name'] = player_name
+1588                rebuilt_json[player_id]['team_name'] = team_name
+1589                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1590                rebuilt_json[player_id]['passing_COMP'] = s_num
+1591
+1592            elif s_type == "ATT":
+1593                rebuilt_json[player_id]['player_name'] = player_name
+1594                rebuilt_json[player_id]['team_name'] = team_name
+1595                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1596                rebuilt_json[player_id]['passing_ATT'] = s_num
+1597
+1598            elif s_type == "YDS":
+1599                rebuilt_json[player_id]['player_name'] = player_name
+1600                rebuilt_json[player_id]['team_name'] = team_name
+1601                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1602                rebuilt_json[player_id]['passing_YDS'] = s_num
+1603
+1604            elif s_type == "TD":
+1605                rebuilt_json[player_id]['player_name'] = player_name
+1606                rebuilt_json[player_id]['team_name'] = team_name
+1607                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1608                rebuilt_json[player_id]['passing_TD'] = s_num
+1609
+1610            elif s_type == "INT":
+1611                rebuilt_json[player_id]['player_name'] = player_name
+1612                rebuilt_json[player_id]['team_name'] = team_name
+1613                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1614                rebuilt_json[player_id]['passing_INT'] = s_num
+1615            # we can calculate these two later
+1616            elif s_type == "PCT":
+1617                pass
+1618
+1619            elif s_type == "YPA":
+1620                pass
+1621
+1622            else:
+1623                raise ValueError(f"Unhandled stat type: {s_type}")
+1624
+1625        elif s_category == "rushing":
+1626            if s_type == "CAR":
+1627                rebuilt_json[player_id]['player_name'] = player_name
+1628                rebuilt_json[player_id]['team_name'] = team_name
+1629                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1630                rebuilt_json[player_id]['rushing_CAR'] = s_num
+1631
+1632            elif s_type == "YDS":
+1633                rebuilt_json[player_id]['player_name'] = player_name
+1634                rebuilt_json[player_id]['team_name'] = team_name
+1635                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1636                rebuilt_json[player_id]['rushing_YDS'] = s_num
+1637
+1638            elif s_type == "TD":
+1639                rebuilt_json[player_id]['player_name'] = player_name
+1640                rebuilt_json[player_id]['team_name'] = team_name
+1641                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1642                rebuilt_json[player_id]['rushing_TD'] = s_num
+1643
+1644            elif s_type == "LONG":
+1645                rebuilt_json[player_id]['player_name'] = player_name
+1646                rebuilt_json[player_id]['team_name'] = team_name
+1647                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1648                rebuilt_json[player_id]['rushing_LONG'] = s_num
+1649            # we can calculate this later
+1650            elif s_type == "YPC":
+1651                pass
+1652
+1653            else:
+1654                raise ValueError(f"Unhandled stat type: {s_type}")
+1655
+1656        elif s_category == "receiving":
+1657            if s_type == "REC":
+1658                rebuilt_json[player_id]['player_name'] = player_name
+1659                rebuilt_json[player_id]['team_name'] = team_name
+1660                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1661                rebuilt_json[player_id]['receiving_REC'] = s_num
+1662
+1663            elif s_type == "YDS":
+1664                rebuilt_json[player_id]['player_name'] = player_name
+1665                rebuilt_json[player_id]['team_name'] = team_name
+1666                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1667                rebuilt_json[player_id]['receiving_YDS'] = s_num
+1668
+1669            elif s_type == "TD":
+1670                rebuilt_json[player_id]['player_name'] = player_name
+1671                rebuilt_json[player_id]['team_name'] = team_name
+1672                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1673                rebuilt_json[player_id]['receiving_TD'] = s_num
+1674
+1675            elif s_type == "LONG":
+1676                rebuilt_json[player_id]['player_name'] = player_name
+1677                rebuilt_json[player_id]['team_name'] = team_name
+1678                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1679                rebuilt_json[player_id]['receiving_LONG'] = s_num
+1680            # we can calculate this later
+1681            elif s_type == "YPR":
+1682                pass
+1683
+1684            else:
+1685                raise ValueError(f"Unhandled stat type: {s_type}")
+1686
+1687        elif s_category == "fumbles":
+1688            if s_type == "FUM":
+1689                rebuilt_json[player_id]['player_name'] = player_name
+1690                rebuilt_json[player_id]['team_name'] = team_name
+1691                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1692                rebuilt_json[player_id]['fumbles_FUM'] = s_num
+1693
+1694            elif s_type == "LOST":
+1695                rebuilt_json[player_id]['player_name'] = player_name
+1696                rebuilt_json[player_id]['team_name'] = team_name
+1697                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1698                rebuilt_json[player_id]['fumbles_LOST'] = s_num
+1699
+1700            elif s_type == "REC":
+1701                rebuilt_json[player_id]['player_name'] = player_name
+1702                rebuilt_json[player_id]['team_name'] = team_name
+1703                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1704                rebuilt_json[player_id]['fumbles_LOST'] = s_num
+1705
+1706            else:
+1707                raise ValueError(f"Unhandled stat type: {s_type}")
+1708
+1709        elif s_category == "defensive":
+1710            if s_type == "TOT":
+1711                rebuilt_json[player_id]['player_name'] = player_name
+1712                rebuilt_json[player_id]['team_name'] = team_name
+1713                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1714                rebuilt_json[player_id]['defensive_TOT'] = s_num
+1715
+1716            elif s_type == "SOLO":
+1717                rebuilt_json[player_id]['player_name'] = player_name
+1718                rebuilt_json[player_id]['team_name'] = team_name
+1719                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1720                rebuilt_json[player_id]['defensive_SOLO'] = s_num
+1721
+1722            elif s_type == "TFL":
+1723                rebuilt_json[player_id]['player_name'] = player_name
+1724                rebuilt_json[player_id]['team_name'] = team_name
+1725                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1726                rebuilt_json[player_id]['defensive_TFL'] = s_num
+1727
+1728            elif s_type == "QB HUR":
+1729                rebuilt_json[player_id]['player_name'] = player_name
+1730                rebuilt_json[player_id]['team_name'] = team_name
+1731                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1732                rebuilt_json[player_id]['defensive_QB HUR'] = s_num
+1733
+1734            elif s_type == "SACKS":
+1735                rebuilt_json[player_id]['player_name'] = player_name
+1736                rebuilt_json[player_id]['team_name'] = team_name
+1737                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1738                rebuilt_json[player_id]['defensive_SACKS'] = s_num
+1739
+1740            elif s_type == "PD":
+1741                rebuilt_json[player_id]['player_name'] = player_name
+1742                rebuilt_json[player_id]['team_name'] = team_name
+1743                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1744                rebuilt_json[player_id]['defensive_PD'] = s_num
+1745
+1746            elif s_type == "TD":
+1747                rebuilt_json[player_id]['player_name'] = player_name
+1748                rebuilt_json[player_id]['team_name'] = team_name
+1749                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1750                rebuilt_json[player_id]['defensive_TD'] = s_num
+1751
+1752            else:
+1753                raise ValueError(f"Unhandled stat type: {s_type}")
+1754
+1755        elif s_category == "interceptions":
+1756            if s_type == "INT":
+1757                rebuilt_json[player_id]['player_name'] = player_name
+1758                rebuilt_json[player_id]['team_name'] = team_name
+1759                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1760                rebuilt_json[player_id]['interceptions_INT'] = s_num
+1761
+1762            elif s_type == "YDS":
+1763                rebuilt_json[player_id]['player_name'] = player_name
+1764                rebuilt_json[player_id]['team_name'] = team_name
+1765                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1766                rebuilt_json[player_id]['interceptions_YDS'] = s_num
+1767
+1768            elif s_type == "TD":
+1769                rebuilt_json[player_id]['player_name'] = player_name
+1770                rebuilt_json[player_id]['team_name'] = team_name
+1771                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1772                rebuilt_json[player_id]['interceptions_TD'] = s_num
+1773
+1774            elif s_type == "AVG":
+1775                pass
+1776
+1777            else:
+1778                raise ValueError(f"Unhandled stat type: {s_type}")
+1779
+1780        elif s_category == "punting":
+1781            if s_type == "NO":
+1782                rebuilt_json[player_id]['player_name'] = player_name
+1783                rebuilt_json[player_id]['team_name'] = team_name
+1784                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1785                rebuilt_json[player_id]['punting_NO'] = s_num
+1786
+1787            elif s_type == "YDS":
+1788                rebuilt_json[player_id]['player_name'] = player_name
+1789                rebuilt_json[player_id]['team_name'] = team_name
+1790                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1791                rebuilt_json[player_id]['punting_YDS'] = s_num
+1792
+1793            elif s_type == "TB":
+1794                rebuilt_json[player_id]['player_name'] = player_name
+1795                rebuilt_json[player_id]['team_name'] = team_name
+1796                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1797                rebuilt_json[player_id]['punting_TB'] = s_num
+1798
+1799            elif s_type == "In 20":
+1800                rebuilt_json[player_id]['player_name'] = player_name
+1801                rebuilt_json[player_id]['team_name'] = team_name
+1802                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1803                rebuilt_json[player_id]['punting_In 20'] = s_num
+1804
+1805            elif s_type == "LONG":
+1806                rebuilt_json[player_id]['player_name'] = player_name
+1807                rebuilt_json[player_id]['team_name'] = team_name
+1808                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1809                rebuilt_json[player_id]['punting_LONG'] = s_num
+1810
+1811            elif s_type == "YPP":
+1812                pass
+1813
+1814            else:
+1815                raise ValueError(f"Unhandled stat type: {s_type}")
+1816
+1817        elif s_category == "kicking":
+1818            if s_type == "FGM":
+1819                rebuilt_json[player_id]['player_name'] = player_name
+1820                rebuilt_json[player_id]['team_name'] = team_name
+1821                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1822                rebuilt_json[player_id]['kicking_FGM'] = s_num
+1823
+1824            elif s_type == "FGA":
+1825                rebuilt_json[player_id]['player_name'] = player_name
+1826                rebuilt_json[player_id]['team_name'] = team_name
+1827                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1828                rebuilt_json[player_id]['kicking_FGA'] = s_num
+1829
+1830            elif s_type == "LONG":
+1831                rebuilt_json[player_id]['player_name'] = player_name
+1832                rebuilt_json[player_id]['team_name'] = team_name
+1833                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1834                rebuilt_json[player_id]['kicking_LONG'] = s_num
+1835
+1836            elif s_type == "XPM":
+1837                rebuilt_json[player_id]['player_name'] = player_name
+1838                rebuilt_json[player_id]['team_name'] = team_name
+1839                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1840                rebuilt_json[player_id]['kicking_XPM'] = s_num
+1841
+1842            elif s_type == "XPA":
+1843                rebuilt_json[player_id]['player_name'] = player_name
+1844                rebuilt_json[player_id]['team_name'] = team_name
+1845                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1846                rebuilt_json[player_id]['kicking_XPA'] = s_num
+1847
+1848            elif s_type == "PTS":
+1849                pass
+1850
+1851            elif s_type == "PCT":
+1852                pass
+1853
+1854            else:
+1855                raise ValueError(f"Unhandled stat type: {s_type}")
+1856
+1857        elif s_category == "kickReturns":
+1858            if s_type == "NO":
+1859                rebuilt_json[player_id]['player_name'] = player_name
+1860                rebuilt_json[player_id]['team_name'] = team_name
+1861                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1862                rebuilt_json[player_id]['kickReturns_NO'] = s_num
+1863
+1864            elif s_type == "YDS":
+1865                rebuilt_json[player_id]['player_name'] = player_name
+1866                rebuilt_json[player_id]['team_name'] = team_name
+1867                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1868                rebuilt_json[player_id]['kickReturns_YDS'] = s_num
+1869
+1870            elif s_type == "TD":
+1871                rebuilt_json[player_id]['player_name'] = player_name
+1872                rebuilt_json[player_id]['team_name'] = team_name
+1873                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1874                rebuilt_json[player_id]['kickReturns_TD'] = s_num
+1875
+1876            elif s_type == "LONG":
+1877                rebuilt_json[player_id]['player_name'] = player_name
+1878                rebuilt_json[player_id]['team_name'] = team_name
+1879                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1880                rebuilt_json[player_id]['kickReturns_LONG'] = s_num
+1881            # we can calculate this later
+1882            elif s_type == "AVG":
+1883                pass
+1884
+1885            else:
+1886                raise ValueError(f"Unhandled stat type: {s_type}")
+1887
+1888        elif s_category == "puntReturns":
+1889            if s_type == "NO":
+1890                rebuilt_json[player_id]['player_name'] = player_name
+1891                rebuilt_json[player_id]['team_name'] = team_name
+1892                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1893                rebuilt_json[player_id]['puntReturns_NO'] = s_num
+1894
+1895            elif s_type == "YDS":
+1896                rebuilt_json[player_id]['player_name'] = player_name
+1897                rebuilt_json[player_id]['team_name'] = team_name
+1898                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1899                rebuilt_json[player_id]['puntReturns_YDS'] = s_num
+1900
+1901            elif s_type == "TD":
+1902                rebuilt_json[player_id]['player_name'] = player_name
+1903                rebuilt_json[player_id]['team_name'] = team_name
+1904                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1905                rebuilt_json[player_id]['puntReturns_TD'] = s_num
+1906
+1907            elif s_type == "LONG":
+1908                rebuilt_json[player_id]['player_name'] = player_name
+1909                rebuilt_json[player_id]['team_name'] = team_name
+1910                rebuilt_json[player_id]['team_confrence'] = team_confrence
+1911                rebuilt_json[player_id]['puntReturns_LONG'] = s_num
+1912            # we can calculate this later
+1913            elif s_type == "AVG":
+1914                pass
+1915
+1916            else:
+1917                raise ValueError(f"Unhandled stat type: {s_type}")
+1918
+1919        else:
+1920            raise ValueError(f"Unhandled stat category: {s_category}")
+1921
+1922        del player_id, player_name, team_name, team_confrence,\
+1923            s_category, s_type, s_num
+1924
+1925    for key, value in tqdm(rebuilt_json.items()):
+1926        # print(key)
+1927
+1928        # print(value)
+1929        team_name = value['team_name']
+1930        team_confrence = value['team_confrence']
+1931        player_id = key
+1932        player_name = value['player_name']
+1933
+1934        row_df = pd.DataFrame(
+1935            {
+1936                "team_name": team_name,
+1937                "team_confrence": team_confrence,
+1938                "player_id": player_id,
+1939                "player_name": player_name
+1940            },
+1941            index=[0]
+1942        )
+1943        # Passing
+1944        if value.get('passing_COMP') != None:
+1945            row_df['passing_COMP'] = value['passing_COMP']
+1946
+1947        if value.get('passing_ATT') != None:
+1948            row_df['passing_ATT'] = value['passing_ATT']
+1949
+1950        if value.get('passing_YDS') != None:
+1951            row_df['passing_YDS'] = value['passing_YDS']
+1952
+1953        if value.get('passing_TD') != None:
+1954            row_df['passing_TD'] = value['passing_TD']
+1955
+1956        if value.get('passing_INT') != None:
+1957            row_df['passing_INT'] = value['passing_INT']
+1958
+1959        # Rushing
+1960        if value.get('rushing_CAR') != None:
+1961            row_df['rushing_CAR'] = value['rushing_CAR']
+1962
+1963        if value.get('rushing_YDS') != None:
+1964            row_df['rushing_YDS'] = value['rushing_YDS']
+1965
+1966        if value.get('rushing_AVG') != None:
+1967            row_df['rushing_AVG'] = value['rushing_AVG']
+1968
+1969        if value.get('rushing_TD') != None:
+1970            row_df['rushing_TD'] = value['rushing_TD']
+1971
+1972        if value.get('rushing_LONG') != None:
+1973            row_df['rushing_LONG'] = value['rushing_LONG']
+1974
+1975        # Receiving
+1976        if value.get('receiving_REC') != None:
+1977            row_df['receiving_REC'] = value['receiving_REC']
+1978
+1979        if value.get('receiving_YDS') != None:
+1980            row_df['receiving_YDS'] = value['receiving_YDS']
+1981
+1982        if value.get('receiving_TD') != None:
+1983            row_df['receiving_TD'] = value['receiving_TD']
+1984
+1985        if value.get('receiving_LONG') != None:
+1986            row_df['receiving_LONG'] = value['receiving_LONG']
+1987
+1988        # Fumbles
+1989        if value.get('fumbles_FUM') != None:
+1990            row_df['fumbles_FUM'] = value['fumbles_FUM']
+1991
+1992        if value.get('fumbles_LOST') != None:
+1993            row_df['fumbles_LOST'] = value['fumbles_LOST']
+1994
+1995        if value.get('fumbles_REC') != None:
+1996            row_df['fumbles_REC'] = value['fumbles_REC']
+1997
+1998        # Defense
+1999        if value.get('defensive_TOT') != None:
+2000            row_df['defensive_TOT'] = value['defensive_TOT']
+2001
+2002        if value.get('defensive_SOLO') != None:
+2003            row_df['defensive_SOLO'] = value['defensive_SOLO']
+2004
+2005        if value.get('defensive_TFL') != None:
+2006            row_df['defensive_TFL'] = value['defensive_TFL']
+2007
+2008        if value.get('defensive_QB HUR') != None:
+2009            row_df['defensive_QB HUR'] = value['defensive_QB HUR']
+2010
+2011        if value.get('defensive_SACKS') != None:
+2012            row_df['defensive_SACKS'] = value['defensive_SACKS']
+2013
+2014        if value.get('defensive_PD') != None:
+2015            row_df['defensive_PD'] = value['defensive_PD']
+2016
+2017        if value.get('defensive_TD') != None:
+2018            row_df['defensive_TD'] = value['defensive_TD']
+2019
+2020        # interceptions
+2021        if value.get('interceptions_INT') != None:
+2022            row_df['interceptions_INT'] = value['interceptions_INT']
+2023
+2024        if value.get('interceptions_YDS') != None:
+2025            row_df['interceptions_YDS'] = value['interceptions_YDS']
+2026
+2027        if value.get('interceptions_TD') != None:
+2028            row_df['interceptions_TD'] = value['interceptions_TD']
+2029
+2030        # punting
+2031        if value.get('punting_NO') != None:
+2032            row_df['punting_NO'] = value['punting_NO']
+2033
+2034        if value.get('punting_YDS') != None:
+2035            row_df['punting_YDS'] = value['punting_YDS']
+2036
+2037        if value.get('punting_TB') != None:
+2038            row_df['punting_TB'] = value['punting_TB']
+2039
+2040        if value.get('punting_In 20') != None:
+2041            row_df['punting_In 20'] = value['punting_In 20']
+2042
+2043        if value.get('punting_LONG') != None:
+2044            row_df['punting_LONG'] = value['punting_LONG']
+2045
+2046        # kicking
+2047        if value.get('kicking_FGM') != None:
+2048            row_df['kicking_FGM'] = value['kicking_FGM']
+2049
+2050        if value.get('kicking_FGA') != None:
+2051            row_df['kicking_FGA'] = value['kicking_FGA']
+2052
+2053        if value.get('kicking_LONG') != None:
+2054            row_df['kicking_LONG'] = value['kicking_LONG']
+2055
+2056        if value.get('kicking_XPM') != None:
+2057            row_df['kicking_XPM'] = value['kicking_XPM']
+2058
+2059        if value.get('kicking_XPA') != None:
+2060            row_df['kicking_XPA'] = value['kicking_XPA']
+2061
+2062        # kickReturns
+2063        if value.get('kickReturns_NO') != None:
+2064            row_df['kickReturns_NO'] = value['kickReturns_NO']
+2065
+2066        if value.get('kickReturns_YDS') != None:
+2067            row_df['kickReturns_YDS'] = value['kickReturns_YDS']
+2068
+2069        if value.get('kickReturns_AVG') != None:
+2070            row_df['kickReturns_AVG'] = value['kickReturns_AVG']
+2071
+2072        if value.get('kickReturns_TD') != None:
+2073            row_df['kickReturns_TD'] = value['kickReturns_TD']
+2074
+2075        if value.get('kickReturns_LONG') != None:
+2076            row_df['kickReturns_LONG'] = value['kickReturns_LONG']
+2077
+2078        # puntReturns
+2079        if value.get('puntReturns_NO') != None:
+2080            row_df['puntReturns_NO'] = value['puntReturns_NO']
+2081
+2082        if value.get('puntReturns_YDS') != None:
+2083            row_df['puntReturns_YDS'] = value['puntReturns_YDS']
+2084
+2085        if value.get('puntReturns_AVG') != None:
+2086            row_df['puntReturns_AVG'] = value['puntReturns_AVG']
+2087
+2088        if value.get('puntReturns_TD') != None:
+2089            row_df['puntReturns_TD'] = value['puntReturns_TD']
+2090
+2091        if value.get('puntReturns_LONG') != None:
+2092            row_df['puntReturns_LONG'] = value['puntReturns_LONG']
+2093
+2094        final_df = pd.concat([final_df, row_df], ignore_index=True)
+2095        del row_df
+2096
+2097    final_df = final_df.fillna(0)
+2098
+2099    final_df['season'] = season
+2100
+2101    if filter_by_stat_category == False:
+2102        final_df = final_df.reindex(columns=stat_columns)
+2103        final_df = final_df.astype({
+2104            "passing_COMP": "int",
+2105            "passing_ATT": "int",
+2106            "rushing_CAR": "int",
+2107            "rushing_YDS": "int",
+2108            "receiving_REC": "int",
+2109            "receiving_YDS": "int",
+2110            "punting_NO": "int",
+2111            "punting_YDS": "int",
+2112            "kicking_FGM": "int",
+2113            "kicking_FGA": "int",
+2114            "kicking_XPM": "int",
+2115            "kicking_XPA": "int",
+2116            "kickReturns_NO": "int",
+2117            "kickReturns_YDS": "int",
+2118            "puntReturns_NO": "int",
+2119            "puntReturns_YDS": "int",
+2120
+2121        })
+2122
+2123        final_df.loc[
+2124            final_df['passing_ATT'] > 0, 'passing_COMP%'] = final_df['passing_COMP'] / final_df['passing_ATT']
+2125
+2126        final_df.loc[
+2127            final_df['rushing_CAR'] > 0, 'rushing_AVG'] = final_df['rushing_YDS'] / final_df['rushing_CAR']
+2128
+2129        final_df.loc[
+2130            final_df['receiving_REC'] > 0, 'receiving_AVG'] = final_df['receiving_YDS']/final_df['receiving_REC']
+2131
+2132
+2133        final_df.loc[
+2134            final_df['punting_NO'] > 0, 'punting_AVG'] = final_df['punting_YDS']/final_df['punting_NO']
+2135
+2136        final_df.loc[
+2137            final_df['kicking_FGA'] > 0, 'kicking_FG%'] = final_df['kicking_FGM']/final_df['kicking_FGA']
+2138
+2139        final_df.loc[
+2140            final_df['kicking_XPA'] > 0, 'kicking_XP%'] = final_df['kicking_XPM']/final_df['kicking_XPA']
+2141
+2142        final_df.loc[
+2143            final_df['kickReturns_NO'] > 0, 'kickReturns_AVG'] = final_df['kickReturns_YDS']/final_df['kickReturns_NO']
+2144
+2145        final_df.loc[
+2146            final_df['puntReturns_NO'] > 0, 'puntReturns_AVG'] = final_df['puntReturns_YDS']/final_df['puntReturns_NO']
+2147
+2148
+2149    elif filter_by_stat_category == True and stat_category == "passing":
+2150        try:
+2151            final_df = final_df.astype({
+2152                "passing_COMP": "int",
+2153                "passing_ATT": "int",
+2154            })
+2155        except:
+2156            logging.warning(
+2157                "Could not reformat [passing_COMP] and [passing_ATT] into integers."
+2158            )
+2159
+2160        final_df.loc[
+2161            final_df['passing_ATT'] >= 1, 'passing_COMP%'] = final_df['passing_COMP'] / final_df['passing_ATT']
+2162
+2163        final_df = final_df[[
+2164            'season',
+2165            'team_name',
+2166            'team_confrence',
+2167            'player_id',
+2168            'player_name',
+2169            # PASS
+2170            'passing_COMP',
+2171            'passing_ATT',
+2172            'passing_YDS',
+2173            'passing_TD',
+2174            'passing_INT',
+2175        ]]
+2176
+2177    elif filter_by_stat_category == True and stat_category == "rushing":
+2178        try:
+2179            final_df = final_df.astype({
+2180                "rushing_CAR": "int",
+2181                "rushing_YDS": "int",
+2182            })
+2183        except:
+2184            logging.warning(
+2185                "Could not reformat [rushing_CAR] and [rushing_YDS] into integers."
+2186            )
+2187
+2188        final_df.loc[
+2189            final_df['rushing_CAR'] >= 1, 'rushing_AVG'] = final_df['rushing_YDS'] / final_df['rushing_CAR']
+2190
+2191        final_df = final_df[[
+2192            'season',
+2193            'team_name',
+2194            'team_confrence',
+2195            'player_id',
+2196            'player_name',
+2197            # RUSH
+2198            'rushing_CAR',
+2199            'rushing_YDS',
+2200            'rushing_AVG',
+2201            'rushing_TD',
+2202            'rushing_LONG',
+2203        ]]
+2204
+2205    elif filter_by_stat_category == True and stat_category == "receiving":
+2206        try:
+2207            final_df = final_df.astype({
+2208                "receiving_REC": "int",
+2209                "receiving_YDS": "int",
+2210            })
+2211        except:
+2212            logging.warning(
+2213                "Could not reformat [receiving_REC] and [receiving_YDS] into integers."
+2214            )
+2215
+2216        final_df.loc[
+2217            final_df['receiving_REC'] > 0, 'receiving_AVG'] = final_df['receiving_YDS']/final_df['receiving_REC']
+2218
+2219        final_df = final_df[[
+2220            'season',
+2221            'team_name',
+2222            'team_confrence',
+2223            'player_id',
+2224            'player_name',
+2225            # REC
+2226            'receiving_REC',
+2227            'receiving_YDS',
+2228            'receiving_AVG',
+2229            'receiving_TD',
+2230            'receiving_LONG'
+2231        ]]
+2232
+2233    elif filter_by_stat_category == True and stat_category == "fumbles":
+2234        final_df = final_df[[
+2235            'season',
+2236            'team_name',
+2237            'team_confrence',
+2238            'player_id',
+2239            'player_name',
+2240            # FUM
+2241            'fumbles_FUM',
+2242            'fumbles_LOST',
+2243            'fumbles_REC'
+2244        ]]
+2245
+2246    elif filter_by_stat_category == True and stat_category == "defensive":
+2247        final_df = final_df[[
+2248            'season',
+2249            'team_name',
+2250            'team_confrence',
+2251            'player_id',
+2252            'player_name',
+2253            # DEFENSE
+2254            'defensive_TOT',
+2255            'defensive_SOLO',
+2256            'defensive_TFL',
+2257            'defensive_QB HUR',
+2258            'defensive_SACKS',
+2259            'defensive_PD',
+2260            'defensive_TD'
+2261        ]]
+2262
+2263    elif filter_by_stat_category == True and stat_category == "interceptions":
+2264        final_df = final_df[[
+2265            'season',
+2266            'team_name',
+2267            'team_confrence',
+2268            'player_id',
+2269            'player_name',
+2270            # INT
+2271            'interceptions_INT',
+2272            'interceptions_YDS',
+2273            'interceptions_TD',
+2274        ]]
+2275
+2276    elif filter_by_stat_category == True and stat_category == "punting":
+2277        try:
+2278            final_df = final_df.astype({
+2279                "punting_NO": "int",
+2280                "punting_YDS": "int",
+2281            })
+2282        except:
+2283            logging.warning(
+2284                "Could not reformat [punting_YDS] and [punting_NO] into integers."
+2285            )
+2286
+2287        final_df.loc[
+2288            final_df['punting_NO'] > 0, 'punting_AVG'] = final_df['punting_YDS']/final_df['punting_NO']
+2289
+2290        final_df = final_df[[
+2291            'season',
+2292            'team_name',
+2293            'team_confrence',
+2294            'player_id',
+2295            'player_name',
+2296            # PUNT
+2297            'punting_NO',
+2298            'punting_YDS',
+2299            'punting_AVG',
+2300            'punting_TB',
+2301            'punting_In 20',
+2302            'punting_LONG'
+2303        ]]
+2304
+2305    elif filter_by_stat_category == True and stat_category == "kicking":
+2306        try:
+2307            final_df = final_df.astype({
+2308                "kicking_FGM": "int",
+2309                "kicking_FGA": "int",
+2310                "kicking_XPM": "int",
+2311                "kicking_XPA": "int"
+2312            })
+2313        except:
+2314            logging.warning(
+2315                "Could not reformat the following columns into integers.:"+
+2316                "\n-[kicking_FGM]"+
+2317                "\n-[kicking_FGA]"+
+2318                "\n-[kicking_XPM]"+
+2319                "\n-[kicking_XPA]"
+2320                
+2321            )
+2322
+2323        final_df.loc[
+2324            final_df['kicking_FGA'] > 0, 'kicking_FG%'] = final_df['kicking_FGM']/final_df['kicking_FGA']
+2325
+2326        final_df.loc[
+2327            final_df['kicking_XPA'] > 0, 'kicking_XP%'] = final_df['kicking_XPM']/final_df['kicking_XPA']
+2328
+2329        final_df = final_df[[
+2330            'season',
+2331            'team_name',
+2332            'team_confrence',
+2333            'player_id',
+2334            'player_name',
+2335            # KICK
+2336            'kicking_FGM',
+2337            'kicking_FGA',
+2338            'kicking_FG%',
+2339            'kicking_LONG',
+2340            'kicking_XPM',
+2341            'kicking_XPA'
+2342            'kicking_XP%',
+2343        ]]
+2344
+2345    elif filter_by_stat_category == True and stat_category == "kickReturns":
+2346        try:
+2347            final_df = final_df.astype({
+2348                "kickReturns_NO": "int",
+2349                "kickReturns_YDS": "int",
+2350            })
+2351        except:
+2352            logging.warning(
+2353                "Could not reformat [passing_COMP] and [kickReturns_YDS] into integers."
+2354            )
+2355
+2356
+2357        final_df.loc[
+2358            final_df['kickReturns_NO'] > 0, 'kickReturns_AVG'] = final_df['kickReturns_YDS']/final_df['kickReturns_NO']
+2359
+2360        final_df = final_df[[
+2361            'season',
+2362            'team_name',
+2363            'team_confrence',
+2364            'player_id',
+2365            'player_name',
+2366            # KR
+2367            'kickReturns_NO',
+2368            'kickReturns_YDS',
+2369            'kickReturns_AVG',
+2370            'kickReturns_TD',
+2371            'kickReturns_LONG'
+2372        ]]
+2373
+2374    elif filter_by_stat_category == True and stat_category == "puntReturns":
+2375        try:
+2376            final_df = final_df.astype({
+2377                "puntReturns_NO": "int",
+2378                "puntReturns_YDS": "int",
+2379            })
+2380        except:
+2381            logging.warning(
+2382                "Could not reformat [passing_COMP] and [puntReturns_YDS] into integers."
+2383            )
+2384
+2385
+2386        final_df.loc[
+2387            final_df['puntReturns_NO'] > 0, 'puntReturns_AVG'] = final_df['puntReturns_YDS']/final_df['puntReturns_NO']
+2388
+2389        final_df = final_df[[
+2390            'season',
+2391            'team_name',
+2392            'team_confrence',
+2393            'player_id',
+2394            'player_name',
+2395            # KR
+2396            'puntReturns_NO',
+2397            'puntReturns_YDS',
+2398            'puntReturns_AVG',
+2399            'puntReturns_TD',
+2400            'puntReturns_LONG'
+2401        ]]
+2402
+2403    return final_df
 
- +

Get player season stats, or the stats of players in a specific timeframe, from the CFBD API.

+ +

Parameters

+ +

season (int, mandatory): + Required argument. + Specifies the season you want CFB player season stats from. + This must be specified, otherwise this package, and by extension + the CFBD API, will not accept the request to get CFB player season stats.

+ +

api_key (str, optional): + Semi-optional argument. + If api_key is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If api_key is not null, this function will automatically assume that the + inputted api_key is a valid CFBD API key.

+ +

api_key_dir (str, optional): + Optional argument. + If api_key is set to am empty string, this variable is ignored. + If api_key_dir is null, and api_key is null, + this function will try to find a CFBD API key file in this user's home directory. + If api_key_dir is set to a string, and api_key is null, + this function will assume that api_key_dir is a directory, + and will try to find a CFBD API key file in that directory.

+ +

team (str, optional): + Optional argument. + If you only want CFB player season stats for a team, + regardless if they are the home/away team, + set team to the name of the team you want CFB player season stats from.

+ +

conference_abv (str, optional): + Optional argument. + If you only want player season stats from games + involving teams a specific confrence, + set conference_abv to the abbreviation + of the conference you want stats from.

+ +

start_week (int, semi-optional): + Optional argument. + If you only want player stats for a range of weeks, + set start_week and end_week to + the range of weeks you want season-level data for.

+ +

end_week (int, semi-optional): + Optional argument. + If you only want player stats for a range of weeks, + set start_week and end_week to + the range of weeks you want season-level data for.

+ +

NOTE: If the following conditions are True, a ValueError() +will be raised when calling this function:

+ +
    +
  • start_week < 0
  • +
  • end_week < 0
  • +
  • start_week != None and end_week == None (will be changed in a future version)
  • +
  • start_week == None and end_week != None (will be changed in a future version)
  • +
  • end_week < start_week
  • +
  • end_week = start_week
  • +
+ +

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, + set season_type to "postseason". + If you want both regular and postseason stats, set season_type = "both". + If season_type is set to anything but "regular", "postseason", or "both", + a ValueError() will be raised.

+ +

stat_category (str, optional): + Optional argument. + If only want stats for a specific stat category, + set this variable to that category.

+ +
Valid inputs are:
+- `passing`
+- `rushing`
+- `receiving`
+- `fumbles`
+- `defensive`
+- `interceptions`
+- `punting`
+- `kicking`
+- `kickReturns`
+- `puntReturns`
+
+ +

return_as_dict (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas DataFrame object, + set return_as_dict to True.

+ +

Usage

+ +
import time
+
+from cfbd_json_py.players import get_cfbd_player_season_stats
+
+
+cfbd_key = "tigersAreAwsome"  # placeholder for your CFBD API Key.
+
+if cfbd_key != "tigersAreAwsome":
+    print("Using the user's API key declared in this script for this example.")
+
+    # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.
+    print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2020,
+        team="Ohio"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player season stats for teams who competed in 
+    # the Southeastern Confrence (SEC) in the 2023 CFB season.
+    print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2020,
+        conference_abv="SEC"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player season stats for teams who competed in 
+    # the Southeastern Confrence (SEC) in the 2023 CFB season,
+    # but only between weeks 1 and 5.
+    print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2020,
+        conference_abv="SEC",
+        start_week=1,
+        end_week=5
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get player season stats for the 2020 CFB season.
+    print("Get player season stats for the 2020 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get player season stats for 
+    # the Ohio Bobcats Football team in the 2022 CFB season, 
+    # but only use regular season games when calculating season stats.
+    print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2022,
+        team="Ohio",
+        season_type="regular"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get passing stats for teams who competed in 
+    # the Southeastern Confrence (SEC) in the 2023 CFB season.
+    print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2020,
+        conference_abv="SEC",
+        stat_category="passing"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = get_cfbd_player_season_stats(
+        api_key=cfbd_key,
+        season=2020,
+        team="LSU",
+        stat_category="kicking",
+        return_as_dict=True
+    )
+    print(json_data)
+
+else:
+    # Alternatively, if the CFBD API key exists in this python environment,
+    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),
+    # you could just call these functions directly, without setting the API key
+    # in the script.
+    print("Using the user's API key suposedly loaded into this python environment for this example.")
+
+    # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.
+    print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        season=2020,
+        team="Ohio"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player season stats for teams who competed in 
+    # the Southeastern Confrence (SEC) in the 2023 CFB season.
+    print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        season=2020,
+        conference_abv="SEC"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get player season stats for teams who competed in 
+    # the Southeastern Confrence (SEC) in the 2023 CFB season,
+    # but only between weeks 1 and 5.
+    print("Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        season=2020,
+        conference_abv="SEC",
+        start_week=1,
+        end_week=5
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get player season stats for the 2020 CFB season.
+    print("Get player season stats for the 2020 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        season=2020
+    )
+    print(json_data)
+    time.sleep(5)
+
+
+    # Get player season stats for 
+    # the Ohio Bobcats Football team in the 2022 CFB season, 
+    # but only use regular season games when calculating season stats.
+    print("Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.")
+    json_data = get_cfbd_player_season_stats(
+        season=2022,
+        team="Ohio",
+        season_type="regular"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # Get passing stats for teams who competed in 
+    # the Southeastern Confrence (SEC) in the 2023 CFB season.
+    print("Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.")
+    json_data = get_cfbd_player_season_stats(
+        season=2020,
+        conference_abv="SEC",
+        stat_category="passing"
+    )
+    print(json_data)
+    time.sleep(5)
+
+    # You can also tell this function to just return the API call as
+    # a Dictionary (read: JSON) object.
+    print("You can also tell this function to just return the API call as a Dictionary (read: JSON) object.")
+    json_data = get_cfbd_player_season_stats(
+        season=2020,
+        team="LSU",
+        stat_category="kicking",
+        return_as_dict=True
+    )
+    print(json_data)
+
+
+
+ +

Returns

+ +

A pandas DataFrame object with a list of players who matched the search string, +or (if return_as_dict is set to True) +a dictionary object with a list of players who matched the search string.

+
+

@@ -301,22 +6001,188 @@

-
80def get_cfbd_transfer_portal_data(
-81        season: int,
-82        api_key: str = None,
-83        api_key_dir: str = None,
-84
-85        return_as_dict: bool = False):
-86    """
-87
-88    """
-89    raise NotImplementedError(
-90        'This function has yet to be implemented by this version.'
-91    )
+            
2406def get_cfbd_transfer_portal_data(
+2407        season: int,
+2408        api_key: str = None,
+2409        api_key_dir: str = None,
+2410        return_as_dict: bool = False):
+2411    """
+2412    Get player usage data (A.K.A., the percentages for how often a player touched the ball),
+2413    for a given season, from the CFBD API.
+2414
+2415    Parameters
+2416    ----------
+2417    `season` (int, mandatory):
+2418        Required argument.
+2419        Specifies the season you want CFB transfer portal data from.
+2420        This must be specified, otherwise this package, and by extension
+2421        the CFBD API, will not accept the request to get CFB transfer portal data stats.
+2422    
+2423    `api_key` (str, optional):
+2424        Semi-optional argument. 
+2425        If `api_key` is null, this function will attempt to load a CFBD API key
+2426        from the python environment, or from a file on this computer.
+2427        If `api_key` is not null, this function will automatically assume that the
+2428        inputted `api_key` is a valid CFBD API key.
+2429
+2430    `api_key_dir` (str, optional):
+2431        Optional argument.
+2432        If `api_key` is set to am empty string, this variable is ignored.
+2433        If `api_key_dir` is null, and `api_key` is null, 
+2434        this function will try to find a CFBD API key file in this user's home directory.
+2435        If `api_key_dir` is set to a string, and `api_key` is null,
+2436        this function will assume that `api_key_dir` is a directory, 
+2437        and will try to find a CFBD API key file in that directory.
+2438
+2439    `return_as_dict` (bool, semi-optional):
+2440        Semi-optional argument.
+2441        If you want this function to return the data as a dictionary (read: JSON object), 
+2442        instead of a pandas `DataFrame` object,
+2443        set `return_as_dict` to `True`.
+2444
+2445    Usage
+2446    ----------
+2447    ```
+2448    ```
+2449    Returns
+2450    ----------
+2451    A pandas `DataFrame` object with transfer portal data, 
+2452    or (if `return_as_dict` is set to `True`) 
+2453    a dictionary object with transfer portal data.
+2454
+2455    """
+2456    now = datetime.now()
+2457    url = "https://api.collegefootballdata.com/player/portal"
+2458
+2459    portal_df = pd.DataFrame()
+2460    row_df = pd.DataFrame()
+2461
+2462    if api_key != None:
+2463        real_api_key = api_key
+2464        del api_key
+2465    else:
+2466        real_api_key = get_cfbd_api_token(api_key_dir=api_key_dir)
+2467
+2468    if real_api_key == "tigersAreAwsome":
+2469        raise ValueError(
+2470            "You actually need to change `cfbd_key` to your CFBD API key.")
+2471    elif "Bearer " in real_api_key:
+2472        pass
+2473    elif "Bearer" in real_api_key:
+2474        real_api_key = real_api_key.replace('Bearer', 'Bearer ')
+2475    else:
+2476        real_api_key = "Bearer " + real_api_key
+2477
+2478    if season == None:
+2479        # This should never happen without user tampering, but if it does,
+2480        # we need to raise an error, because the CFBD API will refuse this call without a valid season.
+2481        raise SystemError(
+2482            "I don't know how, I don't know why, " +
+2483            "but you managed to call this function while `season` was `None` (NULL)," +
+2484            " and the function got to this point in the code." +
+2485            "\nIf you have a GitHub account, " +
+2486            "please raise an issue on this python package's GitHub page:\n" +
+2487            "https://github.com/armstjc/cfbd-json-py/issues"
+2488        )
+2489    elif season > (now.year + 1):
+2490        raise ValueError(f"`season` cannot be greater than {season}.")
+2491    elif season < 2017:
+2492        raise ValueError(f"Transfer portal wasn't really a thing in {season}.")
+2493
+2494    # URL builder
+2495    ########################################################################################################################################################################################################
+2496
+2497    ## required by API
+2498    url += f"?year={season}"
+2499
+2500    headers = {
+2501        'Authorization': f'{real_api_key}',
+2502        'accept': 'application/json'
+2503    }
+2504
+2505
+2506    response = requests.get(url, headers=headers)
+2507
+2508    if response.status_code == 200:
+2509        pass
+2510    elif response.status_code == 401:
+2511        raise ConnectionRefusedError(
+2512            f'Could not connect. The connection was refused.\nHTTP Status Code 401.'
+2513        )
+2514    else:
+2515        raise ConnectionError(
+2516            f'Could not connect.\nHTTP Status code {response.status_code}'
+2517        )
+2518
+2519    json_data = response.json()
+2520
+2521    if return_as_dict == True:
+2522        return json_data
+2523
+2524    for player in tqdm(json_data):
+2525        row_df = pd.DataFrame({"season":season},index=[0])
+2526        row_df['first_name'] = player['firstName']
+2527        row_df['last_name'] = player['lastName']
+2528        row_df['position'] = player['position']
+2529        row_df['origin_team'] = player['origin']
+2530        row_df['destination_team'] = player['destination']
+2531        row_df['transferDate'] = player['transferDate']
+2532        row_df['player_rating'] = player['rating']
+2533        row_df['player_stars'] = player['stars']
+2534        row_df['player_eligibility'] = player['eligibility']
+2535        portal_df = pd.concat([portal_df,row_df],ignore_index=True)
+2536        
+2537        del row_df
+2538
+2539    return portal_df
 
- +

Get player usage data (A.K.A., the percentages for how often a player touched the ball), +for a given season, from the CFBD API.

+ +

Parameters

+ +

season (int, mandatory): + Required argument. + Specifies the season you want CFB transfer portal data from. + This must be specified, otherwise this package, and by extension + the CFBD API, will not accept the request to get CFB transfer portal data stats.

+ +

api_key (str, optional): + Semi-optional argument. + If api_key is null, this function will attempt to load a CFBD API key + from the python environment, or from a file on this computer. + If api_key is not null, this function will automatically assume that the + inputted api_key is a valid CFBD API key.

+ +

api_key_dir (str, optional): + Optional argument. + If api_key is set to am empty string, this variable is ignored. + If api_key_dir is null, and api_key is null, + this function will try to find a CFBD API key file in this user's home directory. + If api_key_dir is set to a string, and api_key is null, + this function will assume that api_key_dir is a directory, + and will try to find a CFBD API key file in that directory.

+ +

return_as_dict (bool, semi-optional): + Semi-optional argument. + If you want this function to return the data as a dictionary (read: JSON object), + instead of a pandas DataFrame object, + set return_as_dict to True.

+ +

Usage

+ +

+
+ +

Returns

+ +

A pandas DataFrame object with transfer portal data, +or (if return_as_dict is set to True) +a dictionary object with transfer portal data.

+
+ diff --git a/docs/search.js b/docs/search.js index 9f1eb0f..a8c89fa 100644 --- a/docs/search.js +++ b/docs/search.js @@ -1,6 +1,6 @@ window.pdocSearch = (function(){ /** elasticlunr - http://weixsong.github.io * Copyright (C) 2017 Oliver Nightingale * Copyright (C) 2017 Wei Song * MIT Licensed */!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();oWelcome!

\n\n

This is the official docs page for the cfbd_json_py python package.

\n\n

To the left of this page are various endpoints for this python package.

\n\n
    \n
  • cfbd_json_py.betting: \nHolds functions for betting lines and betting data from the CFBD API.
  • \n
  • cfbd_json_py.coaches: \nHolds functions for you to get coaching data (past and present).
  • \n
  • cfbd_json_py.conferences: \nHolds functions for you to get information for CFB confrences.
  • \n
  • cfbd_json_py.draft: \nHolds functions for you to get NFL draft information/data for \nvarious players in the CFBD API
  • \n
  • cfbd_json_py.drives: \nHolds functions for you to get data for offensive and/or defensive drives \nwithin the CFBD API.
  • \n
  • cfbd_json_py.games: \nHolds functions for you to get various datapoints pertaining to \nactual CFB games within the CFBD API.
  • \n
  • cfbd_json_py.metrics: \nHolds functions to allow you to calculate or retrive various advanced metrics \nfrom the CFBD API.
  • \n
  • cfbd_json_py.players: \nHolds functions for you to get various \ndata endpoints related to player stats, \nplayer information, and player data.
  • \n
  • cfbd_json_py.plays: \nHolds functions for play-by-play (PBP) data for CFB games, \nas well as a way to calculate stats from PBP data.
  • \n
  • cfbd_json_py.rankings: \nHolds functions for various CFB team ranking polls, \nand their results.
  • \n
  • cfbd_json_py.ratings: \nHolds functions to allow you to get various team ratings data \n(like SP+, SRS, and Elo team ratings) from the CFBD API.
  • \n
  • cfbd_json_py.recruiting: \nHolds functions for you to access CFB recruting data and information, \nas well as team and player ratings for recruiting.
  • \n
  • cfbd_json_py.stats: \nHolds functions for you to get various team stats from the CFBD API.
  • \n
  • cfbd_json_py.teams: \nHolds functions for you to get team information and data, \nas well as head-to-head records and matchup history.
  • \n
  • cfbd_json_py.utls: \nVarious utilities that can be used from this package.\nOutside of cfbd_json_py.utls.set_cfbd_api_token(), \nyou don't need to call any of these functions directly.
  • \n
  • cfbd_json_py.venues: \nHolds functions for you to get information on \nvarious venues/stadiums within the college football world.
  • \n
\n\n

Basic Setup

\n\n

If you have a CFBD API key, you have three ways to set it for this python package to use:

\n\n
    \n
  1. Declare the API key as a string variable in a python script (not reccomended, extreme security risk).
  2. \n
  3. Declare the API key in your environment as CFBD_API_KEY.\n
      \n
    • cfbd_json_py will first look for your environment, \nif you don't declare the API key as a string variable, \nwhen calling any function in this python package that uses a CFBD API call.
    • \n
    • If you're using GitHub Actions with this package, \njust set a repository secret with the name CFBD_API_KEY. \nAgain, this package will automatically know where to look, \nif you've set your API key in the environment
    • \n
  4. \n
  5. Use cfbd_json_py.utls.set_cfbd_api_token() to store the API key in an encrypted file on your machine.\n
      \n
    • To set the API key for this package with this function, \nrun this code in a python script, \nreplacing \"TigersAreAwesome\" with your API key:
    • \n
  6. \n
\n\n
from cfbd_api_key.utls import set_cfbd_api_token\n\ncfbd_api_key = \"TigersAreAwesome\" # replace this with your actual API key\nset_cfbd_api_token(api_key=cfbd_api_key)\n
\n\n
\n

NOTE: In a future version, \n there will be an executable application seperate from this package\n for Windows, Mac, and Linux users to effectively do the same thing \n as the above code block, but with a graphical user interface (GUI).

\n
\n\n

If you want to see how to use this python package after setting up your API key,\nclick on one of the submodules on the left \nto view the various functions within each submodule.\nEach function has a tutorial script on the various ways you can call that function.

\n\n

Other Notes

\n\n
    \n
  • If you want to see all CFBD API endpoints that are currently supported, \nclick here\nto access the current Swagger docs for the entire API.
  • \n
  • If you want to see the source code for this package, \nclick here to see the current stable build of this python package on GitHub.
  • \n
  • If you want to see the active changelog for this python package, \nclick here to view the changelog of this python package on GitHub.
  • \n
\n"}, {"fullname": "cfbd_json_py.betting", "modulename": "cfbd_json_py.betting", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.betting.get_cfbd_betting_lines", "modulename": "cfbd_json_py.betting", "qualname": "get_cfbd_betting_lines", "kind": "function", "doc": "

Retrives betting information from the CFBD API for a given season, \nor you could only get betting information for a single game.

\n\n

Parameters

\n\n

season (int, mandatory):\n The season you want to retrive betting information from.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

game_id (int, optional):\n Optional argument. \n If game_id is set to a game ID, get_cfb_betting_lines() will try to get \n all betting informaiton for that game ID.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load betting data from games in that season, and that week.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want postseason betting data, set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

team (str, optional):\n Optional argument.\n If you only want betting information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want game-level betting data from.

\n\n

home_team (str, optional):\n Optional argument.\n If you only want betting information for a team, \n where that team was the home team in this season,\n set home_team to the name of the team you want game-level betting data from.

\n\n

away_team (str, optional):\n Optional argument.\n If you only want betting information for a team, \n where that team was the away team in this season,\n set away_team to the name of the team you want game-level betting data from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want betting information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want betting informaiton from.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.betting import get_cfbd_betting_lines\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets all available betting info for the 2020 CFB season.\n    print(\"Gets all available betting info for the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Gets all available betting info for the 2020 CFB season, in week 2.\n    print(\"Gets all available betting info for the 2020 CFB season, in week 2.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        week=2\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\n    print(\"Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\n    print(\"Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        home_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        away_team=\"Ohio State\"\n    )\n\n    # Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\n    print(\"Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets all available betting info for the 2020 CFB season.\n    print(\"Gets all available betting info for the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all available betting info for the 2020 CFB season, in week 2.\n    print(\"Gets all available betting info for the 2020 CFB season, in week 2.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        week=2\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\n    print(\"Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\n    print(\"Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        home_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n\n        season=2020,\n        away_team=\"Ohio State\"\n    )\n\n    # Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\n    print(\"Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football betting data, \nor (if return_as_dict is set to True) \na dictionary object with college football betting data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tgame_id: int = None,\tweek: int = None,\tseason_type: str = 'regular',\tteam: str = None,\thome_team: str = None,\taway_team: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.coaches", "modulename": "cfbd_json_py.coaches", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.coaches.get_cfbd_coaches_info", "modulename": "cfbd_json_py.coaches", "qualname": "get_cfbd_coaches_info", "kind": "function", "doc": "

Retrives information from the CFBD API on CFB Head Coaches.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

first_name (str, optional):\n Optional argument.\n If you want to only look up coaches with a specific first name, \n set this variable to that specific first name, and this function \n will attempt to look up coaches with that specific first name.

\n\n

last_name (str, optional):\n Optional argument.\n If you want to only look up coaches with a specific last name, \n set this variable to that specific first name, and this function \n will attempt to look up coaches with that specific last name.

\n\n

team (str, optional):\n Optional argument.\n If you want to filter and drill down to coaches who coached a specific\n CFB team, set this

\n\n

season (int, optional):\n Optional argument.\n If you only want coaches from a specific season, set this variable to that season.

\n\n

min_season (int, optional):\n Optional argument.\n Similar to year, but used in tandem with max_season to get coaches who coached with in a range of seasons.

\n\n

max_season (int, optional):\n Optional argument.\n Similar to year, but used in tandem with min_season to get coaches who coached with in a range of seasons.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.coaches import get_cfbd_coaches_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Getting all coaches in the 2020 CFB season\n    print(\"Getting every coach in the 2020 CFB season.\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n    # Getting all coaches in the 2020 CFB season, with a first name of \"Luke\"\n    print(\"Getting every coach in the 2020 CFB season, with a first name of \"Luke\".\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020,\n        first_name=\"Luke\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting all coaches in the 2020 CFB season, with a last name of \"Day\"\n    print(\"Getting all coaches in the 2020 CFB season, with a last name of \"Day\".\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020,\n        last_name=\"Day\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach for the 2020 Southern Mississippi Golden Eagles\n    print(\"Getting every head coach for the 2020 Southern Mississippi Golden Eagles.\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Southern Mississippi\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach between the 2019 and 2022 CFB seasons\n    print(\"Getting every head coach between the 2019 and 2022 CFB seasons\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        min_season=2019,\n        max_season=2022\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2022,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(f\"{json_data}\")\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Getting every coach in the 2020 CFB season.\n    print(\"Getting every coach in the 2020 CFB season.\")\n    json_data = get_cfbd_coaches_info(season=2020)\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every coach in the 2020 CFB season, with a first name of \"Luke\".\n    print(\"Getting every coach in the 2020 CFB season, with a first name of \"Luke\".\")\n    json_data = get_cfbd_coaches_info(\n        season=2020,\n        first_name=\"Luke\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every coach in the 2020 CFB season, with a last name of \"Day\".\n    print(\"Getting every coach in the 2020 CFB season, with a last name of \"Day\".\")\n    json_data = get_cfbd_coaches_info(\n        season=2020,\n        last_name=\"Day\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach for the 2020 Southern Mississippi Golden Eagles.\n    print(\"Getting every head coach for the 2020 Southern Mississippi Golden Eagles.\")\n    json_data = get_cfbd_coaches_info(\n        season=2020,\n        team=\"Southern Mississippi\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach between the 2019 and 2022 CFB seasons.\n    print(\"Getting every head coach between the 2019 and 2022 CFB seasons.\")\n    json_data = get_cfbd_coaches_info(\n        min_season=2019,\n        max_season=2022\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_coaches_info(\n        season=2022,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(f\"{json_data}\")\n\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB head coach data, \nor (if return_as_dict is set to True) \na dictionary object with CFB head coach data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tfirst_name: str = None,\tlast_name: str = None,\tteam: str = None,\tseason: int = None,\tmin_season: int = None,\tmax_season: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.conferences", "modulename": "cfbd_json_py.conferences", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.conferences.get_cfbd_conference_info", "modulename": "cfbd_json_py.conferences", "qualname": "get_cfbd_conference_info", "kind": "function", "doc": "

Retrives a list of CFB conferences from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.conferences import get_cfbd_conference_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets CFB confrence info from the CFBD API.\n    print(\"Gets CFB confrence info from the CFBD API.\")\n    json_data = get_cfbd_conference_info(api_key=cfbd_key)\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_conference_info(\n        api_key=cfbd_key,\n        return_as_dict=True)\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets CFB confrence info from the CFBD API.\n    print(\"Gets CFB confrence info from the CFBD API.\")\n    json_data = get_cfbd_conference_info()\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_conference_info(return_as_dict=True)\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB conference data, \nor (if return_as_dict is set to True) \na dictionary object with CFB conference data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.draft", "modulename": "cfbd_json_py.draft", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.draft.get_cfbd_nfl_teams", "modulename": "cfbd_json_py.draft", "qualname": "get_cfbd_nfl_teams", "kind": "function", "doc": "

Retrives a list of NFL teams from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.draft import get_cfbd_nfl_teams\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets NFL team info from the CFBD API.\n    print(\"Gets NFL team info from the CFBD API.\")\n    json_data = get_cfbd_nfl_teams(api_key=cfbd_key)\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_teams(\n        api_key=cfbd_key,\n        return_as_dict=True)\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets NFL team info from the CFBD API.\n    print(\"Gets NFL team info from the CFBD API.\")\n    json_data = get_cfbd_nfl_teams()\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_teams(return_as_dict=True)\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with NFL team data, \nor (if return_as_dict is set to True) \na dictionary object with NFL team data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.draft.get_cfbd_nfl_positions", "modulename": "cfbd_json_py.draft", "qualname": "get_cfbd_nfl_positions", "kind": "function", "doc": "

Retrives a list of player positions for the NFL Draft from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.draft import get_cfbd_nfl_positions\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets a list of player positions for the NFL Draft from the CFBD API.\n    print(\"Gets a list of player positions for the NFL Draft from the CFBD API.\")\n    json_data = get_cfbd_nfl_positions(api_key=cfbd_key)\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_positions(\n        api_key=cfbd_key,\n        return_as_dict=True)\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets a list of player positions for the NFL Draft from the CFBD API.\n    print(\"Gets a list of player positions for the NFL Draft from the CFBD API.\")\n    json_data = get_cfbd_nfl_positions()\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_positions(return_as_dict=True)\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player position data, \nor (if return_as_dict is set to True) \na dictionary object with player position data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.draft.get_cfbd_nfl_draft_info", "modulename": "cfbd_json_py.draft", "qualname": "get_cfbd_nfl_draft_info", "kind": "function", "doc": "

Retrives a list of actual NFL Draft selections from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

The following paramaters are optional, but it is highly reccomended to not call this function\nwithiout settting one of these five optional paramaters to a non-null value.

\n\n

season (int, semi-optional):\n Semi-Optional argument. \n This is the season you want NFL Draft information for. For example, if you only want \n data for the 2020 NFL Draft, set season to 2020.

\n\n

nfl_team (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections from a specific NFL team, set nfl_team to the \n name of that team. For example, if you want to only get NFL Draft information for \n draft picks made by the Cincinnati Bengals, set nfl_team to Cincinnati.

\n\n

college (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections from a specific CFB team, set college to the \n name of that team. For example, if you want to only get NFL Draft information for \n draft picks from the Clemson Tigers Football Program, set college to Clemson.

\n\n

conference (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections from a specific CFB confrence, set conference to the abbreviation of that confrence. \n A list of CFBD API confrence abbreviations can be found in the conference_abbreviation column from \n the pandas DataFrame that is returned by calling cfbd_json_py.conferences.get_cfbd_conference_info().\n For example, if you want to only get NFL Draft information for \n draft picks that played in the Big 12, set confrence to B12.

\n\n

position (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections who played a specific position, \n set position to that position's abbreviation. \n A list of CFBD API positions can be found in the position_abbreviation column from \n the pandas DataFrame that is returned by calling cfbd_json_py.draft.get_cfbd_nfl_positions().

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.draft import get_cfbd_nfl_draft_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get NFL Draft selections from the 2020 NFL Draft.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made by the\n    # 2020 Cincinnati Bengals.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made by the 2020 Cincinnati Bengals.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        nfl_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # Clemson Tigers football players.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving Clemson Tigers football players.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        college=\"Clemson\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # players who played in the Southeastern Confrence (SEC).\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving players who played in the Southeastern Confrence (SEC).\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        conference=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made\n    # where the selected player was a QB in college.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made where the selected player was a QB in college.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        position=\"QB\",\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get NFL Draft selections from the 2020 NFL Draft.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft.\")\n    json_data = get_cfbd_nfl_draft_info(season=2020)\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made by the\n    # 2020 Cincinnati Bengals.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made by the 2020 Cincinnati Bengals.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        nfl_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # Clemson Tigers football players.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving Clemson Tigers football players.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        college=\"Clemson\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # players who played in the Southeastern Confrence (SEC).\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving players who played in the Southeastern Confrence (SEC).\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        conference=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made\n    # where the selected player was a QB in college.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made where the selected player was a QB in college.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        position=\"QB\",\n        return_as_dict=True\n    )\n    print(json_data)\n
\n\n

Returns

\n\n

A pandas DataFrame object with NFL Draft selection data, \nor (if return_as_dict is set to True) \na dictionary object with NFL Draft selection data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tnfl_team: str = None,\tcollege: str = None,\tconference_abv: str = None,\tposition: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.drives", "modulename": "cfbd_json_py.drives", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.drives.get_cfbd_drives_info", "modulename": "cfbd_json_py.drives", "qualname": "get_cfbd_drives_info", "kind": "function", "doc": "

Retrives a list of CFB drives from the CFBD API.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB drive information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB drive information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB drive data for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB drive data from games in that season, and that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB drive data for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB drive data from.

\n\n

offensive_team (str, optional):\n Optional argument.\n If you only want CFB drive data from a team, while they are on offense, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB drive data from.

\n\n

defensive_team (str, optional):\n Optional argument.\n If you only want CFB drive data from a team, while they are on defense,\n regardless if they are the home/away team,\n set team to the name of the team you want CFB drive data from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want CFB drive data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want CFB drive data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

offensive_conference_abv (str, optional):\n Optional argument.\n If you only want CFB drive data from games \n where the offensive team is from a specific confrenece,\n set conference_abv to the abbreviation \n of the conference you want CFB drive data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

defensive_conference_abv (str, optional):\n Optional argument.\n If you only want CFB drive data from games \n where the defensive team is from a specific confrenece,\n set conference_abv to the abbreviation \n of the conference you want CFB drive data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

ncaa_division (str, semi-optional):\n Semi-optional argument.\n By default, ncaa_division will be set to \"fbs\", \n short for the Football Bowl Subdivision (FBS), \n formerly known as D1-A (read as \"division one single A\"),\n the highest level in the NCAA football pyramid,\n where teams can scolarship up to 85 players \n on their football team soley for athletic ability, \n and often have the largest athletics budgets\n within the NCAA.

\n\n
Other valid inputs are:\n- \"fcs\": Football Championship Subdivision (FCS), \n    formerly known as D1-AA (read as \"division one double A\").\n    An FCS school is still in the 1st division of the NCAA,\n    making them elligable for the March Madness tournament,\n    but may not have the resources to compete at the FBS level\n    at this time. FCS schools are limited to 63 athletic scolarships\n    for football.\n- \"ii\": NCAA Division II. Schools in this and D3 are not\n    elligable for the March Madness tournament, \n    and are limited to 36 athletic scolarships for their football team.\n- \"iii\": NCAA Division III. The largest single division within the \n    NCAA football pyramid. \n    D3 schools have the distinction of being part of \n    the only NCAA division that cannot give out scolarships soley \n    for athletic ability.\n
\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.drives import get_cfbd_drives_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get CFB Drive data from the 2020 CFB season.\n    print(\"Get CFB Drive data from the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from week 10 of the 2020 CFB season.\n    print(\"Get CFB Drive data from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Cincinnati Bearcats\n    # Football Team.\n    print(\"Get CFB Drive data from games involving the 2020 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio Bobcats\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio Bobcats Football Team, when Ohio was on offense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        offensive_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio State Buckeyes\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        defensive_team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 12 games in the 2020 CFB season.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B12\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 10 (B1G) games in the 2020 CFB season,\n    # where the Big 10 team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        offensive_conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from  Mid-American Conference (MAC) games\n    # in the 2020 CFB season, where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        defensive_conference_abv=\"MAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Football Championship Subdivision (FCS) games\n    # in week 3 ofthe 2020 CFB season,\n    # where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        week=3,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get CFB Drive data from the 2020 CFB season.\n    print(\"Get CFB Drive data from the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from week 10 of the 2020 CFB season.\n    print(\"Get CFB Drive data from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Cincinnati Bearcats\n    # Football Team.\n    print(\"Get CFB Drive data from games involving the 2020 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio Bobcats\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio Bobcats Football Team, when Ohio was on offense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        offensive_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio State Buckeyes\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        defensive_team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 12 games in the 2020 CFB season.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        conference_abv=\"B12\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 10 (B1G) games in the 2020 CFB season,\n    # where the Big 10 team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        offensive_conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from  Mid-American Conference (MAC) games\n    # in the 2020 CFB season, where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        defensive_conference_abv=\"MAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Football Championship Subdivision (FCS) games\n    # in week 3 ofthe 2020 CFB season,\n    # where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=3,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB drive data, \nor (if return_as_dict is set to True) \na dictionary object with CFB drive data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\toffensive_team: str = None,\tdefensive_team: str = None,\tconference_abv: str = None,\toffensive_conference_abv: str = None,\tdefensive_conference_abv: str = None,\tncaa_division: str = 'fbs',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games", "modulename": "cfbd_json_py.games", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.games.get_cfbd_games", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_games", "kind": "function", "doc": "

Retrives game schedule data from the CFBD API.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB game information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB game information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB game information for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB game data from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB game information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB game information from.

\n\n

home_team (str, optional):\n Optional argument.\n If you only want game information for a team, \n where that team was the home team in this season,\n set home_team to the name of the team you want game information for.

\n\n

away_team (str, optional):\n Optional argument.\n If you only want game information for a team, \n where that team was the away team in this season,\n set away_team to the name of the team you want game information for.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want game information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want game information from.

\n\n

ncaa_division (str, semi-optional):\n Semi-optional argument.\n By default, ncaa_division will be set to \"fbs\", \n short for the Football Bowl Subdivision (FBS), \n formerly known as D1-A (read as \"division one single A\"),\n the highest level in the NCAA football pyramid,\n where teams can scolarship up to 85 players \n on their football team soley for athletic ability, \n and often have the largest athletics budgets\n within the NCAA.

\n\n
Other valid inputs are:\n- \"fcs\": Football Championship Subdivision (FCS), \n    formerly known as D1-AA (read as \"division one double A\").\n    An FCS school is still in the 1st division of the NCAA,\n    making them elligable for the March Madness tournament,\n    but may not have the resources to compete at the FBS level\n    at this time. FCS schools are limited to 63 athletic scolarships\n    for football.\n- \"ii\": NCAA Division II. Schools in this and D3 are not\n    elligable for the March Madness tournament, \n    and are limited to 36 athletic scolarships for their football team.\n- \"iii\": NCAA Division III. The largest single division within the \n    NCAA football pyramid. \n    D3 schools have the distinction of being part of \n    the only NCAA division that cannot give out scolarships soley \n    for athletic ability.\n
\n\n

game_id (int, optional):\n Optional argument. \n If game_id is set to a game ID, get_cfb_betting_lines() will try to get \n game information just for that game ID.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_games\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get CFB games from the 2020 CFB season.\n    print(\"Get CFB games from the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from week 10 of the 2020 CFB season.\n    print(\"Get CFB games from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\n    print(\"Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\n    print(\"Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2021,\n        home_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2019,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2022 college football games where one or more teams competing\n    # was a Football Championship Subdivision team.\n    print(\"Get 2022 college football games where one or more teams competing was a Football Championship Subdivision team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get game information for the\n    # 2021 American Athletic Confrence (AAC) Championship Game.\n    print(\"Get game information for the 2021 American Athletic Confrence (AAC) Championship Game.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2018,\n        game_id=401331162\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_games(\n        season=2020,\n        week=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get CFB games from the 2020 CFB season.\n    print(\"Get CFB games from the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from week 10 of the 2020 CFB season.\n    print(\"Get CFB games from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\n    print(\"Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\")\n    json_data = get_cfbd_games(\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\n    print(\"Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\")\n    json_data = get_cfbd_games(\n        season=2021,\n        home_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        season=2019,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2022 college football games where one or more teams competing\n    # was a Football Championship Subdivision team.\n    print(\"Get 2022 college football games where one or more teams competing was a Football Championship Subdivision team.\")\n    json_data = get_cfbd_games(\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get game information for the\n    # 2021 American Athletic Confrence (AAC) Championship Game.\n    print(\"Get game information for the 2021 American Athletic Confrence (AAC) Championship Game.\")\n    json_data = get_cfbd_games(\n        season=2018,\n        game_id=401331162\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_games(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football game information, \nor (if return_as_dict is set to True) \na dictionary object with college football game information.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\thome_team: str = None,\taway_team: str = None,\tconference_abv: str = None,\tncaa_division: str = 'fbs',\tgame_id: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_team_records", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_team_records", "kind": "function", "doc": "

Get a team, or multiple team's record (wins, losses, ties) for home games, away games, \nconfrence games, and the team's record for that season.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want CFB team records data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want CFB team records data for a specific team,\n set team to the name of the team you want CFB drive data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want CFB team records data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want CFB team records data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_team_records\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get CFB team records from the 2020 CFB season.\n    print(\"Get CFB team records from the 2020 CFB season.\")\n    json_data = get_cfbd_team_records(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams fielded by the University of Cincinnati.\n    print(\"Get team records from football teams fielded by the University of Cincinnati.\")\n    json_data = get_cfbd_team_records(\n        api_key=cfbd_key,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams that played in the Big 10 (B1G) Confrence\n    # in the 2017 CFB season\n    print(\"Get team records from football teams that played in the Big 10 (B1G) Confrence in the 2017 CFB season\")\n    json_data = get_cfbd_team_records(\n        api_key=cfbd_key,\n        season=2017,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_records(\n        season=2020,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get CFB team records from the 2020 CFB season.\n    print(\"Get CFB team records from the 2020 CFB season.\")\n    json_data = get_cfbd_team_records(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams fielded by the University of Cincinnati.\n    print(\"Get team records from football teams fielded by the University of Cincinnati.\")\n    json_data = get_cfbd_team_records(\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams that played in the Big 10 (B1G) Confrence\n    # in the 2017 CFB season\n    print(\"Get team records from football teams that played in the Big 10 (B1G) Confrence in the 2017 CFB season\")\n    json_data = get_cfbd_team_records(\n        season=2017,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_records(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB team records data, \nor (if return_as_dict is set to True)\na dictionary object with CFB team records data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_season_weeks", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_season_weeks", "kind": "function", "doc": "

Retrives a list of weeks that occured in a given CFB season.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want a list of weeks that occured in a given CFB season information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get a list of weeks that occured in a given CFB season information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_season_weeks\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get a list of weeks in the 2020 CFB season.\n    print(\"Get a list of weeks in the 2020 CFB season.\")\n    json_data = get_cfbd_season_weeks(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_season_weeks(\n        season=2020,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get a list of weeks in the 2020 CFB season.\n    print(\"Get a list of weeks in the 2020 CFB season.\")\n    json_data = get_cfbd_season_weeks(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_season_weeks(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with a list of valid weeks in a given CFB season, \nor (if return_as_dict is set to True)\na dictionary object with a list of valid weeks in a given CFB season.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_game_media_info", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_game_media_info", "kind": "function", "doc": "

Gets known media information for CFB games in a given CFB season.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB media information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB media information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB media information for non-regular season games, \n set season_type to \"postseason\".\n If you want both \"regular\" and \"postseason\" games retunred, \n set season_type to \"both\"\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB media information from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB media information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB media information from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want media information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want game information from.

\n\n

media_type (str, semi-optional):\n Semi-optional argument.\n If you only want game broadcast information for a specific type of broadcast,\n set this to the type of broadcast.

\n\n
Valid inputs are: \n- `all` (default): Returns all games, and all known broadcasters for those games.\n- `tv`: Returns all known TV broadcasters for CFB games in the requested timeframe.\n- `radio`: Returns all known radio broadcasters \n    for CFB games in the requested timeframe.\n- `web`: Returns all known web broadcasts (like ESPN+) \n    for CFB games in the requested timeframe.\n- `ppv`: Returns all known Pay Per View (PPV) broadcasts \n    for CFB games in the requested timeframe.\n- `mobile`: Returns all known broadcasters that only broadcasted \n    games on mobile devices (?)\n
\n\n

ncaa_division (str, semi-optional):\n Semi-optional argument.\n By default, ncaa_division will be set to \"fbs\", \n short for the Football Bowl Subdivision (FBS), \n formerly known as D1-A (read as \"division one single A\"),\n the highest level in the NCAA football pyramid,\n where teams can scolarship up to 85 players \n on their football team soley for athletic ability, \n and often have the largest athletics budgets\n within the NCAA.

\n\n
Other valid inputs are:\n- \"fcs\": Football Championship Subdivision (FCS), \n    formerly known as D1-AA (read as \"division one double A\").\n    An FCS school is still in the 1st division of the NCAA,\n    making them elligable for the March Madness tournament,\n    but may not have the resources to compete at the FBS level\n    at this time. FCS schools are limited to 63 athletic scolarships\n    for football.\n- \"ii\": NCAA Division II. Schools in this and D3 are not\n    elligable for the March Madness tournament, \n    and are limited to 36 athletic scolarships for their football team.\n- \"iii\": NCAA Division III. The largest single division within the \n    NCAA football pyramid. \n    D3 schools have the distinction of being part of \n    the only NCAA division that cannot give out scolarships soley \n    for athletic ability.\n
\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_game_media_info\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get a media information for the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for postseason games in the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for week 10 games in the 2020 CFB season.\n    print(\"Get a media information for week 10 games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\n    print(\"Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\n    print(\"Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"AAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games in the the 2020 CFB season.\n    print(\"Get all known radio broadcasters for games in the the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        media_type=\"radio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\n    print(\"Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get a media information for the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for postseason games in the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for week 10 games in the 2020 CFB season.\n    print(\"Get a media information for week 10 games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\n    print(\"Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\n    print(\"Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        conference_abv=\"AAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games in the the 2020 CFB season.\n    print(\"Get all known radio broadcasters for games in the the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        media_type=\"radio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\n    print(\"Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football media information, \nor (if return_as_dict is set to True) \na dictionary object with college football media information.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\tconference_abv: str = None,\tmedia_type: str = 'all',\tncaa_division: str = 'fbs',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_player_game_stats", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_player_game_stats", "kind": "function", "doc": "

Retrives player game stats for a given time frame.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB media information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB media information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB media information for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

For the following three variables, \nat least one must be set to a non-null variable when calling this function.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB media information from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB media information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB media information from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want media information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want game information from.

\n\n

stat_category (str, optional):\n Optional argument.\n If only want stats for a specific stat category, \n set this variable to that category.

\n\n
Valid inputs are:\n- `passing`\n- `rushing`\n- `receiving`\n- `fumbles`\n- `defensive`\n- `interceptions`\n- `punting`\n- `kicking`\n- `kickReturns`\n- `puntReturns`\n
\n\n

game_id (int, optional):\n Optional argument. \n If game_id is set to a game ID, get_cfbd_player_game_stats() will try to get \n player game stats just for that game ID.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_player_game_stats\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player game stats for week 10 of the 2020 CFB season.\n    print(\"Get player game stats for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get postseason player game stats for the 2020 CFB season.\n    print(\"Get postseason player game stats for the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\",\n        week=1\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\n    print(\"Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2018,\n        team=\"Alabama\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\n    print(\"Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get get passing stats from players who played in week 7 of the 2017 CFB season.\n    print(\"Get get passing stats from players who played in week 7 of the 2017 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2017,\n        week=7,\n        stat_category=\"pasing\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats from the 2021 Virbo Citrus Bowl, \n    # a bowl game that happened in the 2020 CFB season.\n    print(\"Get player game stats from the 2021 Virbo Citrus Bowl, a bowl game that happened in the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        game_id=401256199\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        week=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player game stats for week 10 of the 2020 CFB season.\n    print(\"Get player game stats for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get postseason player game stats for the 2020 CFB season.\n    print(\"Get postseason player game stats for the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        season_type=\"postseason\",\n        week=1\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\n    print(\"Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2018,\n        team=\"Alabama\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\n    print(\"Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get get passing stats from players who played in week 7 of the 2017 CFB season.\n    print(\"Get get passing stats from players who played in week 7 of the 2017 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2017,\n        week=7,\n        stat_category=\"passing\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats from the 2021 Virbo Citrus Bowl, \n    # a bowl game that happened in the 2020 CFB season,\n    # between the Aubrun Tigers, and the Northwestern Wildcats.\n    print(\"Get player game stats from the 2021 Virbo Citrus Bowl, \"+\n        \"a bowl game that happened in the 2020 CFB season between the Aubrun Tigers, and the Northwestern Wildcats.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        game_id=401256199\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player game stats data, \nor (if return_as_dict is set to True) \na dictionary object with player game stats data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\tconference_abv: str = None,\tstat_category: str = None,\tgame_id: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_player_advanced_game_stats", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_player_advanced_game_stats", "kind": "function", "doc": "

Retrives advanced game stats from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_player_advanced_game_stats\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, \n    # and the Oklahoma Sooners Football Program.\n    print(\"Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        api_key=cfbd_key,\n        game_id=401135278\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        api_key=cfbd_key,\n        game_id=401135278,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, \n    # and the Oklahoma Sooners Football Program.\n    print(\"Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        game_id=401135278\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        game_id=401135278,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football game information, \nor (if return_as_dict is set to True) \na dictionary object with college football game information.

\n", "signature": "(\tgame_id: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_live_scoreboard", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_live_scoreboard", "kind": "function", "doc": "

YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!\nTo view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tncaa_division: str = 'fbs',\tconference: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_weather_info", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_weather_info", "kind": "function", "doc": "

YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!\nTo view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tncaa_division: str = 'fbs',\tgame_id: int = None,\tseason: int = None,\tweek: int = None,\tseason_type: str = 'regular',\tconference: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics", "modulename": "cfbd_json_py.metrics", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_predicted_ppa_from_down_distance", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_predicted_ppa_from_down_distance", "kind": "function", "doc": "

Given a down and distance, \nthis function will attempt to get the predicted\nPPA value for that down and distance, \nat every yard line possible for that down and distance.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

For this endpoint, \n[yardLine] is the number of yards from 1 (offense has the ball on their side, \nat their 1 yard line), to 99 \n(offense with the ball with a X and goal situation on the opponent's 1 yard line.

\n\n

Parameters

\n\n

down (int, mandatory):\n Mandatory argument.\n This is the down (a number between 1 and 4 in normal situations)\n for this play you want PPA for.

\n\n

distance (int, mandatory):\n Mandatory argument.\n This variable should be set to the number of yards between \n the line of scrimage (LOS), and the first down line on the field.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_predicted_ppa_from_down_distance\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get the predicted PPA for a 1st and 10 play, \n    # in every possible situation.\n    print(\"Get the predicted PPA for a 1st and 10 play, in every possible situation.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10,\n        api_key=cfbd_key\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n\n    # Get the predicted PPA for a 1st and 10 play, \n    # in every possible situation.\n    print(\"Get the predicted PPA for a 1st and 10 play, in every possible situation.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with a calculated PPA from a dwon and distance, \nor (if return_as_dict is set to True) \na dictionary object with a calculated PPA from a dwon and distance.

\n", "signature": "(\tdown: int,\tdistance: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_team_season_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_team_season_ppa_data", "kind": "function", "doc": "

Allows you to get team PPA data, \nover an entire season,\nwith or without garbage time plays, \nfor a specificed team and/or time period.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want team PPA data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want team PPA data for a specific team,\n set team to the name of the team you want team PPA data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want team PPA data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want team PPA data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_team_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get team season PPA data for the 2020 CFB season.\n    print(\"Get team PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes, \n    # but exclude garbage time plays when making the PPA calculations.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes, but exclude garbage time plays when making the PPA calculations.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio State\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\n    print(\"Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B1G\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get team season PPA data for the 2020 CFB season.\n    print(\"Get team PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes, \n    # but exclude garbage time plays when making the PPA calculations.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes, but exclude garbage time plays when making the PPA calculations.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        team=\"Ohio State\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\n    print(\"Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        conference_abv=\"B1G\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with team season PPA data, \nor (if return_as_dict is set to True) \na dictionary object with a team season PPA data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\texclude_garbage_time: bool = False,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_team_game_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_team_game_ppa_data", "kind": "function", "doc": "

Allows you to get team PPA data, \nat a game level,\nwith or without garbage time plays, \nfor a specificed team and/or time period.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want team game PPA data information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get team game PPA data information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load team game PPA data from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want team game PPA data for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want team game PPA data from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want team game PPA data from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want team game PPA data from.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want team game PPA data for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_team_game_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get team PPA data for individual games within the 2020 CFB season.\n    print(\"Get team PPA data for individual games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for week 10 games within the 2020 CFB season.\n    print(\"Get team PPA data for week 10 games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for \n    # University of Cincinnati football games within the 2020 CFB season.\n    print(\"Get team PPA data for University of Cincinnati football games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season, but exclude plays that occur in garbage time.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season, but exclude plays that occur in garbage time.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for postseason games in the 2020 CFB season.\n    print(\"Get team PPA data for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get team PPA data for individual games within the 2020 CFB season.\n    print(\"Get team PPA data for individual games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for week 10 games within the 2020 CFB season.\n    print(\"Get team PPA data for week 10 games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for \n    # University of Cincinnati football games within the 2020 CFB season.\n    print(\"Get team PPA data for University of Cincinnati football games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season, but exclude plays that occur in garbage time.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season, but exclude plays that occur in garbage time.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        conference_abv=\"SEC\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for postseason games in the 2020 CFB season.\n    print(\"Get team PPA data for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with team PPA data, \nor (if return_as_dict is set to True) \na dictionary object with team PPA data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\tconference_abv: str = None,\texclude_garbage_time: bool = False,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_player_game_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_player_game_ppa_data", "kind": "function", "doc": "

Allows you to get player PPA data, \nat a game level,\nwith or without garbage time plays, \nfor a specificed time period and/or team.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, semi-optional):\n Semi-Optional argument.\n Specifies the season you want player game PPA data information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get player game PPA data information.

\n\n

week (int, semi-optional):\n Semi-Optional argument.\n If week is set to an integer, this function will attempt \n to load player game PPA data from games in that season, and in that week.\n week and/or team must be set to a non-null value for this function \n to work.

\n\n

team (str, semi-optional):\n Semi-Optional argument.\n If you only want player game PPA data for players of a specific team, \n regardless if they are the home/away team,\n set team to the name of the team you want player game PPA data from.\n week and/or team must be set to a non-null value for this function \n to work.

\n\n

position (str, optional):\n Optional argument.\n If you only want player game PPA data for players of a specific position, \n set position to the position you want player game PPA data from.

\n\n

player_id (int, optional):\n Optional argument.\n If you only want PPA data for a specific player ID, \n set this variable to the player ID of the player you want PPA data from.

\n\n

play_threshold\n Optional argument.\n If you only want PPA data for players \n who touched the ball for X number of plays in a game,\n set play_threshold = x, where x is \n your specified minimum number of plays.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want player game PPA data for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_player_game_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player game PPA data for week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for players of the \n    # 2020 University of Cincinnati Football team.\n    print(\"Get player game PPA data for players of the 2020 University of Cincinnati Football team.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season, \n    # but exclude plays in garbage time.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, but exclude plays in garbage time.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        position=\"QB\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for week 10 of the 2020 CFB season,\n    # where a player touched the ball for at least 25 plays.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, where a player touched the ball for at least 25 plays.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        play_threshold=25\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data the 2020 Alabama Crimson Tide Football team, \n    # during their postseason.\n    print(\"Get player game PPA data the 2020 Alabama Crimson Tide Football team, during their postseason.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Alabama\",\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player game PPA data for week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for players of the \n    # 2020 University of Cincinnati Football team.\n    print(\"Get player game PPA data for players of the 2020 University of Cincinnati Football team.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season, \n    # but exclude plays in garbage time.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, but exclude plays in garbage time.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        position=\"QB\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for week 10 of the 2020 CFB season,\n    # where a player touched the ball for at least 25 plays.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, where a player touched the ball for at least 25 plays.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        play_threshold=25\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data the 2020 Alabama Crimson Tide Football team, \n    # during their postseason.\n    print(\"Get player game PPA data the 2020 Alabama Crimson Tide Football team, during their postseason.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        team=\"Alabama\",\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player PPA data, \nor (if return_as_dict is set to True) \na dictionary object with player PPA data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tweek: int = None,\tteam: str = None,\tposition: str = None,\tplayer_id: int = None,\tplay_threshold: int = None,\texclude_garbage_time: bool = False,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_player_season_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_player_season_ppa_data", "kind": "function", "doc": "

Allows you to get player PPA data, \nat a season level,\nwith or without garbage time plays, \nfor a specificed time period and/or team.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, semi-optional):\n Semi-Optional argument.\n Specifies the season you want player season PPA data information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get player season PPA data information.

\n\n

team (str, semi-optional):\n Semi-Optional argument.\n If you only want player season PPA data for players of a specific team, \n regardless if they are the home/away team,\n set team to the name of the team you want player season PPA data from.\n week and/or team must be set to a non-null value for this function \n to work.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want player season PPA data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want player season PPA data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

position (str, optional):\n Optional argument.\n If you only want player season PPA data for players of a specific position, \n set position to the position you want player season PPA data from.

\n\n

player_id (int, optional):\n Optional argument.\n If you only want PPA data for a specific player ID, \n set this variable to the player ID of the player you want PPA data from.

\n\n

play_threshold\n Optional argument.\n If you only want PPA data for players \n who touched the ball for X number of plays in a game,\n set play_threshold = x, where x is \n your specified minimum number of plays.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_player_season_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player season PPA data for the 2020 CFB season.\n    print(\"Get player season PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 Ohio Bobcats Football Team.\n    print(\"Get player season PPA data for the 2020 Ohio Bobcats Football Team.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data for players who played on\n    # teams within the Southeastern Conference (SEC) for the\n    # 2020 CFB Season.\n    print(\"Get player season PPA data for players who played on teams within the Southeastern Conference (SEC) for the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from QBs in the 2020 CFB Season.\n    print(\"Get player season PPA data from QBs in the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511).\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511).\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        player_id=3915511\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511),\n    # but exclude plays that occured in garbage time.\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511), but exclude plays that occured in garbage time.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        player_id=3915511,\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 CFB Season,\n    # for players with at least 100 plays/touches.\n    print(\"Get player season PPA data from the 2020 CFB Season, for players with at least 100 plays/touches.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        play_threshold=100\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player season PPA data for the 2020 CFB season.\n    print(\"Get player season PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 Ohio Bobcats Football Team.\n    print(\"Get player season PPA data for the 2020 Ohio Bobcats Football Team.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data for players who played on\n    # teams within the Southeastern Conference (SEC) for the\n    # 2020 CFB Season.\n    print(\"Get player season PPA data for players who played on teams within the Southeastern Conference (SEC) for the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from QBs in the 2020 CFB Season.\n    print(\"Get player season PPA data from QBs in the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511).\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511).\")\n    json_data = get_cfbd_player_season_ppa_data(\n        player_id=3915511\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511),\n    # but exclude plays that occured in garbage time.\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511), but exclude plays that occured in garbage time.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        player_id=3915511,\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 CFB Season,\n    # for players with at least 100 plays/touches.\n    print(\"Get player season PPA data from the 2020 CFB Season, for players with at least 100 plays/touches.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        play_threshold=100\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player PPA data, \nor (if return_as_dict is set to True) \na dictionary object with player PPA data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\tposition: str = None,\tplayer_id: int = None,\tplay_threshold: int = None,\texclude_garbage_time: bool = False,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_game_win_probability_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_game_win_probability_data", "kind": "function", "doc": "

Allows one to get win probabliity data for a given game ID.

\n\n

Parameters

\n\n

game_id (int, mandatory):\n Mandatory argument.\n This is the game ID for the game you want win probability data from,\n at the play-by-play level.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_game_win_probability_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get the win probablility data for a 2017 game between \n    # the University of Cincinnati and UConn (game ID #400941851).\n    print(\"Get the win probablility data for a 2017 game between the University of Cincinnati and UConn (game ID #400941851).\")\n    json_data = get_cfbd_game_win_probability_data(\n        api_key=cfbd_key,\n        game_id=400941851\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get the win probablility data for a 2023 game between \n    # the University of Duke and the University of Louisville (game ID #401525535).\n    print(\"Get the win probablility data for a 2023 game between the University of Duke and the University of Louisville (game ID #401525535).\")\n    json_data = get_cfbd_game_win_probability_data(\n        api_key=cfbd_key,\n        game_id=401525535\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_win_probability_data(\n        api_key=cfbd_key,\n        game_id=400941851,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get win probablility data for a 2017 game between \n    # the University of Cincinnati and UConn (game ID #400941851).\n    print(\"Get the win probablility data for a 2017 game between the University of Cincinnati and UConn (game ID #400941851).\")\n    json_data = get_cfbd_game_win_probability_data(\n        game_id=400941851\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get win probablility data for a 2023 game between \n    # the University of Duke and the University of Louisville (game ID #401525535).\n    print(\"Get the win probablility data for a 2023 game between the University of Duke and the University of Louisville (game ID #401525535).\")\n    json_data = get_cfbd_game_win_probability_data(\n        game_id=401525535\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_win_probability_data(\n        game_id=400941851,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with win probability data at the play-by-play level,\nor (if return_as_dict is set to True) \na dictionary object with win probability data at the play-by-play level.

\n", "signature": "(\tgame_id: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_pregame_win_probability_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_pregame_win_probability_data", "kind": "function", "doc": "

Allows you to get pregame win probability data for games within a timeframe.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want pregame win probability data.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB game data from games in that season, and in that week.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want pregame win probability data for a specific team,\n set team to the name of the team you want pregame win probability data from.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB game information for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_pregame_win_probability_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get pregame win probabilities for games in the 2023 CFB season.\n    print(\"Get pregame win probabilities for games in the 2023 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2023\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games in week 10 of the 2021 CFB season.\n    print(\"Get pregame win probabilities for games in week 10 of the 2021 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\n    print(\"Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for postseason games in the 2020 CFB season.\n    print(\"Get pregame win probabilities for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2023,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n# Get pregame win probabilities for games in the 2023 CFB season.\n    print(\"Get pregame win probabilities for games in the 2023 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2023\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games in week 10 of the 2021 CFB season.\n    print(\"Get pregame win probabilities for games in week 10 of the 2021 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\n    print(\"Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for postseason games in the 2020 CFB season.\n    print(\"Get pregame win probabilities for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2023,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with pregame win probability data, \nor (if return_as_dict is set to True) \na dictionary object with a pregame win probability data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players", "modulename": "cfbd_json_py.players", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.players.cfbd_player_search", "modulename": "cfbd_json_py.players", "qualname": "cfbd_player_search", "kind": "function", "doc": "

\n", "signature": "(\tsearch_str: str,\tapi_key: str = None,\tapi_key_dir: str = None,\tposition: str = None,\tteam: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_player_usage", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_player_usage", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tconference_abv: str = None,\tposition: str = None,\tplayer_id: int = None,\texclude_garbage_time: bool = False,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_returning_production", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_returning_production", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_player_season_stats", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_player_season_stats", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tconference_abv: str = None,\tstart_week: int = None,\tend_week: int = None,\tseason_type: str = 'regular',\tstat_category: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_transfer_portal_data", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_transfer_portal_data", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays", "modulename": "cfbd_json_py.plays", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_data", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_data", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\toffensive_team: str = None,\tdefensive_team: str = None,\tconference_abv: str = None,\toffensive_conference_abv: str = None,\tdefensive_conference_abv: str = None,\tplay_type: int = None,\tncaa_division: str = 'fbs',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_play_types", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_play_types", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_stats", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_stats", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\tgame_id: int = None,\tathlete_id: int = None,\tstat_type_id: int = None,\tseason_type: str = 'regular',\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_stat_types", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_stat_types", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_live_pbp_data", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_live_pbp_data", "kind": "function", "doc": "

\n", "signature": "(\tgame_id: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.rankings", "modulename": "cfbd_json_py.rankings", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.rankings.get_cfbd_poll_rankings", "modulename": "cfbd_json_py.rankings", "qualname": "get_cfbd_poll_rankings", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings", "modulename": "cfbd_json_py.ratings", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_sp_plus_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_sp_plus_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_srs_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_srs_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: int = None,\tconferenece: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_sp_plus_conference_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_sp_plus_conference_ratings", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_elo_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_elo_ratings", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tseason_type: str = 'regular',\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.recruiting", "modulename": "cfbd_json_py.recruiting", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.recruiting.get_cfbd_player_recruit_ratings", "modulename": "cfbd_json_py.recruiting", "qualname": "get_cfbd_player_recruit_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\trecruit_classification: str = 'HighSchool',\tposition: str = None,\tstate: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.recruiting.get_cfbd_team_recruiting_ratings", "modulename": "cfbd_json_py.recruiting", "qualname": "get_cfbd_team_recruiting_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.recruiting.get_cfbd_team_recruiting_group_ratings", "modulename": "cfbd_json_py.recruiting", "qualname": "get_cfbd_team_recruiting_group_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tstart_season: int = None,\tend_season: int = None,\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats", "modulename": "cfbd_json_py.stats", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.stats.get_cfbd_team_season_stats", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_team_season_stats", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\tstart_week: int = None,\tend_week: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats.get_cfbd_advanced_team_season_stats", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_advanced_team_season_stats", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\texclude_garbage_time: bool = False,\tstart_week: int = None,\tend_week: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats.get_cfbd_advanced_team_game_stats", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_advanced_team_game_stats", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tweek: int = None,\topponent: str = None,\texclude_garbage_time: bool = False,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats.get_cfbd_team_stat_categories", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_team_stat_categories", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams", "modulename": "cfbd_json_py.teams", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_information", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_information", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_fbs_team_list", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_fbs_team_list", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_rosters", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_rosters", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_talent_rankings", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_talent_rankings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_matchup_history", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_matchup_history", "kind": "function", "doc": "

\n", "signature": "(\tteam_1: str,\tteam_2: str,\tapi_key: str = None,\tapi_key_dir: str = None,\tmin_season: int = None,\tmax_season: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls", "modulename": "cfbd_json_py.utls", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.utls.reverse_cipher_encrypt", "modulename": "cfbd_json_py.utls", "qualname": "reverse_cipher_encrypt", "kind": "function", "doc": "

NOT INTENDED TO BE CALLED BY THE USER!

\n\n

Implements a reverse cipher encription to a plain text string.

\n\n

Parameters

\n\n

plain_text_str (mandatory, str):\n The string you want to encrypt through reverse cipher encryption.

\n\n

Returns

\n\n

A string encrypted through reverse cipher encryption.

\n", "signature": "(plain_text_str: str):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls.reverse_cipher_decrypt", "modulename": "cfbd_json_py.utls", "qualname": "reverse_cipher_decrypt", "kind": "function", "doc": "

NOT INTENDED TO BE CALLED BY THE USER!

\n\n

Decrypts a string that was presumed to be encrypted by a reverse cipher encryption.

\n\n

Parameters

\n\n

encrypted_text_str (mandatory, str):\n The string you presume that is encrypted through reverse cipher encryption, \n that you want decrypted.

\n\n

Returns

\n\n

A decrypted string.

\n", "signature": "(encrypted_text_str: str):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls.get_cfbd_api_token", "modulename": "cfbd_json_py.utls", "qualname": "get_cfbd_api_token", "kind": "function", "doc": "

NOT INTENDED TO BE CALLED BY THE USER!

\n\n

If you've already set the API key using \ncfbd_json_py.utls.set_cfbd_api_token(),\nyou don't need to use this function.

\n\n

If the CFBD API key exists in the environment, \nor is in a file, this function retrives the CFBD API key, \nand returns it as a string.

\n\n

If this package is being used in a GitHub Actions action,\nset the key in the environment by \ncreating a repository secret nammed CFBD_API_KEY.

\n\n

Parameters

\n\n

api_key_dir (str, optional):\n Optional argument. If api_key_dir is set to a non-null string, \n set_cfbd_api_token() will attempt to save the key file in that directory,\n instead of this user's home directory.

\n\n

Returns

\n\n

A CFBD API key that exists within this python environment,\nor within this computer.

\n", "signature": "(api_key_dir: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls.set_cfbd_api_token", "modulename": "cfbd_json_py.utls", "qualname": "set_cfbd_api_token", "kind": "function", "doc": "

Sets the CFBD API key into a file that exists \neither in {home_dir}/.cfbd/cfbd_key.json, or in a custom directory.

\n\n

Parameters

\n\n

api_key (str, mandatory):\n The CFBD API key you have. \n DO NOT input Bearer {your CFBD API key},\n this package will take care of that for you.

\n\n

api_key_dir (str, optional):\n Optional argument. If api_key_dir is set to a non-null string, \n set_cfbd_api_token() will attempt to save the key file in that directory,\n instead of this user's home directory.

\n\n

Returns

\n\n

Nothing. \nThis function only sets up the API key file that this package can reference later.

\n", "signature": "(api_key: str, api_key_dir: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.venues", "modulename": "cfbd_json_py.venues", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.venues.get_cfbd_venues", "modulename": "cfbd_json_py.venues", "qualname": "get_cfbd_venues", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}]; + /** pdoc search index */const docs = [{"fullname": "cfbd_json_py", "modulename": "cfbd_json_py", "kind": "module", "doc": "

Welcome!

\n\n

This is the official docs page for the cfbd_json_py python package.

\n\n

To the left of this page are various endpoints for this python package.

\n\n
    \n
  • cfbd_json_py.betting: \nHolds functions for betting lines and betting data from the CFBD API.
  • \n
  • cfbd_json_py.coaches: \nHolds functions for you to get coaching data (past and present).
  • \n
  • cfbd_json_py.conferences: \nHolds functions for you to get information for CFB confrences.
  • \n
  • cfbd_json_py.draft: \nHolds functions for you to get NFL draft information/data for \nvarious players in the CFBD API
  • \n
  • cfbd_json_py.drives: \nHolds functions for you to get data for offensive and/or defensive drives \nwithin the CFBD API.
  • \n
  • cfbd_json_py.games: \nHolds functions for you to get various datapoints pertaining to \nactual CFB games within the CFBD API.
  • \n
  • cfbd_json_py.metrics: \nHolds functions to allow you to calculate or retrive various advanced metrics \nfrom the CFBD API.
  • \n
  • cfbd_json_py.players: \nHolds functions for you to get various \ndata endpoints related to player stats, \nplayer information, and player data.
  • \n
  • cfbd_json_py.plays: \nHolds functions for play-by-play (PBP) data for CFB games, \nas well as a way to calculate stats from PBP data.
  • \n
  • cfbd_json_py.rankings: \nHolds functions for various CFB team ranking polls, \nand their results.
  • \n
  • cfbd_json_py.ratings: \nHolds functions to allow you to get various team ratings data \n(like SP+, SRS, and Elo team ratings) from the CFBD API.
  • \n
  • cfbd_json_py.recruiting: \nHolds functions for you to access CFB recruting data and information, \nas well as team and player ratings for recruiting.
  • \n
  • cfbd_json_py.stats: \nHolds functions for you to get various team stats from the CFBD API.
  • \n
  • cfbd_json_py.teams: \nHolds functions for you to get team information and data, \nas well as head-to-head records and matchup history.
  • \n
  • cfbd_json_py.utls: \nVarious utilities that can be used from this package.\nOutside of cfbd_json_py.utls.set_cfbd_api_token(), \nyou don't need to call any of these functions directly.
  • \n
  • cfbd_json_py.venues: \nHolds functions for you to get information on \nvarious venues/stadiums within the college football world.
  • \n
\n\n

Basic Setup

\n\n

If you have a CFBD API key, you have three ways to set it for this python package to use:

\n\n
    \n
  1. Declare the API key as a string variable in a python script (not reccomended, extreme security risk).
  2. \n
  3. Declare the API key in your environment as CFBD_API_KEY.\n
      \n
    • cfbd_json_py will first look for your environment, \nif you don't declare the API key as a string variable, \nwhen calling any function in this python package that uses a CFBD API call.
    • \n
    • If you're using GitHub Actions with this package, \njust set a repository secret with the name CFBD_API_KEY. \nAgain, this package will automatically know where to look, \nif you've set your API key in the environment
    • \n
  4. \n
  5. Use cfbd_json_py.utls.set_cfbd_api_token() to store the API key in an encrypted file on your machine.\n
      \n
    • To set the API key for this package with this function, \nrun this code in a python script, \nreplacing \"TigersAreAwesome\" with your API key:
    • \n
  6. \n
\n\n
from cfbd_api_key.utls import set_cfbd_api_token\n\ncfbd_api_key = \"TigersAreAwesome\" # replace this with your actual API key\nset_cfbd_api_token(api_key=cfbd_api_key)\n
\n\n
\n

NOTE: In a future version, \n there will be an executable application seperate from this package\n for Windows, Mac, and Linux users to effectively do the same thing \n as the above code block, but with a graphical user interface (GUI).

\n
\n\n

If you want to see how to use this python package after setting up your API key,\nclick on one of the submodules on the left \nto view the various functions within each submodule.\nEach function has a tutorial script on the various ways you can call that function.

\n\n

Other Notes

\n\n
    \n
  • If you want to see all CFBD API endpoints that are currently supported, \nclick here\nto access the current Swagger docs for the entire API.
  • \n
  • If you want to see the source code for this package, \nclick here to see the current stable build of this python package on GitHub.
  • \n
  • If you want to see the active changelog for this python package, \nclick here to view the changelog of this python package on GitHub.
  • \n
\n"}, {"fullname": "cfbd_json_py.betting", "modulename": "cfbd_json_py.betting", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.betting.get_cfbd_betting_lines", "modulename": "cfbd_json_py.betting", "qualname": "get_cfbd_betting_lines", "kind": "function", "doc": "

Retrives betting information from the CFBD API for a given season, \nor you could only get betting information for a single game.

\n\n

Parameters

\n\n

season (int, mandatory):\n The season you want to retrive betting information from.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

game_id (int, optional):\n Optional argument. \n If game_id is set to a game ID, get_cfb_betting_lines() will try to get \n all betting informaiton for that game ID.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load betting data from games in that season, and that week.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want postseason betting data, set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

team (str, optional):\n Optional argument.\n If you only want betting information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want game-level betting data from.

\n\n

home_team (str, optional):\n Optional argument.\n If you only want betting information for a team, \n where that team was the home team in this season,\n set home_team to the name of the team you want game-level betting data from.

\n\n

away_team (str, optional):\n Optional argument.\n If you only want betting information for a team, \n where that team was the away team in this season,\n set away_team to the name of the team you want game-level betting data from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want betting information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want betting informaiton from.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.betting import get_cfbd_betting_lines\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets all available betting info for the 2020 CFB season.\n    print(\"Gets all available betting info for the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Gets all available betting info for the 2020 CFB season, in week 2.\n    print(\"Gets all available betting info for the 2020 CFB season, in week 2.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        week=2\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\n    print(\"Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\n    print(\"Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        home_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        away_team=\"Ohio State\"\n    )\n\n    # Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\n    print(\"Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_betting_lines(\n        api_key=cfbd_key,\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets all available betting info for the 2020 CFB season.\n    print(\"Gets all available betting info for the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all available betting info for the 2020 CFB season, in week 2.\n    print(\"Gets all available betting info for the 2020 CFB season, in week 2.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        week=2\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\n    print(\"Gets all betting info for the 2020 CFB season, in the postseason (bowls, playoffs, etc.).\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\n    print(\"Gets all betting info for Cincinnati Bearcats Football games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio Bobcats home games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        home_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\n    print(\"Gets all betting info for Ohio State Buckeyes away games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n\n        season=2020,\n        away_team=\"Ohio State\"\n    )\n\n    # Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\n    print(\"Gets all betting info for Atlantic Coast Conference (ACC) games the 2020 CFB season.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_betting_lines(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football betting data, \nor (if return_as_dict is set to True) \na dictionary object with college football betting data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tgame_id: int = None,\tweek: int = None,\tseason_type: str = 'regular',\tteam: str = None,\thome_team: str = None,\taway_team: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.coaches", "modulename": "cfbd_json_py.coaches", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.coaches.get_cfbd_coaches_info", "modulename": "cfbd_json_py.coaches", "qualname": "get_cfbd_coaches_info", "kind": "function", "doc": "

Retrives information from the CFBD API on CFB Head Coaches.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

first_name (str, optional):\n Optional argument.\n If you want to only look up coaches with a specific first name, \n set this variable to that specific first name, and this function \n will attempt to look up coaches with that specific first name.

\n\n

last_name (str, optional):\n Optional argument.\n If you want to only look up coaches with a specific last name, \n set this variable to that specific first name, and this function \n will attempt to look up coaches with that specific last name.

\n\n

team (str, optional):\n Optional argument.\n If you want to filter and drill down to coaches who coached a specific\n CFB team, set this

\n\n

season (int, optional):\n Optional argument.\n If you only want coaches from a specific season, set this variable to that season.

\n\n

min_season (int, optional):\n Optional argument.\n Similar to year, but used in tandem with max_season to get coaches who coached with in a range of seasons.

\n\n

max_season (int, optional):\n Optional argument.\n Similar to year, but used in tandem with min_season to get coaches who coached with in a range of seasons.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.coaches import get_cfbd_coaches_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Getting all coaches in the 2020 CFB season\n    print(\"Getting every coach in the 2020 CFB season.\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n    # Getting all coaches in the 2020 CFB season, with a first name of \"Luke\"\n    print(\"Getting every coach in the 2020 CFB season, with a first name of \"Luke\".\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020,\n        first_name=\"Luke\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting all coaches in the 2020 CFB season, with a last name of \"Day\"\n    print(\"Getting all coaches in the 2020 CFB season, with a last name of \"Day\".\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020,\n        last_name=\"Day\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach for the 2020 Southern Mississippi Golden Eagles\n    print(\"Getting every head coach for the 2020 Southern Mississippi Golden Eagles.\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Southern Mississippi\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach between the 2019 and 2022 CFB seasons\n    print(\"Getting every head coach between the 2019 and 2022 CFB seasons\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        min_season=2019,\n        max_season=2022\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_coaches_info(\n        api_key=cfbd_key,\n        season=2022,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(f\"{json_data}\")\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Getting every coach in the 2020 CFB season.\n    print(\"Getting every coach in the 2020 CFB season.\")\n    json_data = get_cfbd_coaches_info(season=2020)\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every coach in the 2020 CFB season, with a first name of \"Luke\".\n    print(\"Getting every coach in the 2020 CFB season, with a first name of \"Luke\".\")\n    json_data = get_cfbd_coaches_info(\n        season=2020,\n        first_name=\"Luke\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every coach in the 2020 CFB season, with a last name of \"Day\".\n    print(\"Getting every coach in the 2020 CFB season, with a last name of \"Day\".\")\n    json_data = get_cfbd_coaches_info(\n        season=2020,\n        last_name=\"Day\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach for the 2020 Southern Mississippi Golden Eagles.\n    print(\"Getting every head coach for the 2020 Southern Mississippi Golden Eagles.\")\n    json_data = get_cfbd_coaches_info(\n        season=2020,\n        team=\"Southern Mississippi\"\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # Getting every head coach between the 2019 and 2022 CFB seasons.\n    print(\"Getting every head coach between the 2019 and 2022 CFB seasons.\")\n    json_data = get_cfbd_coaches_info(\n        min_season=2019,\n        max_season=2022\n    )\n    print(f\"{json_data}\")\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_coaches_info(\n        season=2022,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(f\"{json_data}\")\n\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB head coach data, \nor (if return_as_dict is set to True) \na dictionary object with CFB head coach data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tfirst_name: str = None,\tlast_name: str = None,\tteam: str = None,\tseason: int = None,\tmin_season: int = None,\tmax_season: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.conferences", "modulename": "cfbd_json_py.conferences", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.conferences.get_cfbd_conference_info", "modulename": "cfbd_json_py.conferences", "qualname": "get_cfbd_conference_info", "kind": "function", "doc": "

Retrives a list of CFB conferences from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.conferences import get_cfbd_conference_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets CFB confrence info from the CFBD API.\n    print(\"Gets CFB confrence info from the CFBD API.\")\n    json_data = get_cfbd_conference_info(api_key=cfbd_key)\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_conference_info(\n        api_key=cfbd_key,\n        return_as_dict=True)\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets CFB confrence info from the CFBD API.\n    print(\"Gets CFB confrence info from the CFBD API.\")\n    json_data = get_cfbd_conference_info()\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_conference_info(return_as_dict=True)\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB conference data, \nor (if return_as_dict is set to True) \na dictionary object with CFB conference data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.draft", "modulename": "cfbd_json_py.draft", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.draft.get_cfbd_nfl_teams", "modulename": "cfbd_json_py.draft", "qualname": "get_cfbd_nfl_teams", "kind": "function", "doc": "

Retrives a list of NFL teams from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.draft import get_cfbd_nfl_teams\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets NFL team info from the CFBD API.\n    print(\"Gets NFL team info from the CFBD API.\")\n    json_data = get_cfbd_nfl_teams(api_key=cfbd_key)\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_teams(\n        api_key=cfbd_key,\n        return_as_dict=True)\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets NFL team info from the CFBD API.\n    print(\"Gets NFL team info from the CFBD API.\")\n    json_data = get_cfbd_nfl_teams()\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_teams(return_as_dict=True)\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with NFL team data, \nor (if return_as_dict is set to True) \na dictionary object with NFL team data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.draft.get_cfbd_nfl_positions", "modulename": "cfbd_json_py.draft", "qualname": "get_cfbd_nfl_positions", "kind": "function", "doc": "

Retrives a list of player positions for the NFL Draft from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.draft import get_cfbd_nfl_positions\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Gets a list of player positions for the NFL Draft from the CFBD API.\n    print(\"Gets a list of player positions for the NFL Draft from the CFBD API.\")\n    json_data = get_cfbd_nfl_positions(api_key=cfbd_key)\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_positions(\n        api_key=cfbd_key,\n        return_as_dict=True)\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Gets a list of player positions for the NFL Draft from the CFBD API.\n    print(\"Gets a list of player positions for the NFL Draft from the CFBD API.\")\n    json_data = get_cfbd_nfl_positions()\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_positions(return_as_dict=True)\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player position data, \nor (if return_as_dict is set to True) \na dictionary object with player position data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.draft.get_cfbd_nfl_draft_info", "modulename": "cfbd_json_py.draft", "qualname": "get_cfbd_nfl_draft_info", "kind": "function", "doc": "

Retrives a list of actual NFL Draft selections from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

The following paramaters are optional, but it is highly reccomended to not call this function\nwithiout settting one of these five optional paramaters to a non-null value.

\n\n

season (int, semi-optional):\n Semi-Optional argument. \n This is the season you want NFL Draft information for. For example, if you only want \n data for the 2020 NFL Draft, set season to 2020.

\n\n

nfl_team (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections from a specific NFL team, set nfl_team to the \n name of that team. For example, if you want to only get NFL Draft information for \n draft picks made by the Cincinnati Bengals, set nfl_team to Cincinnati.

\n\n

college (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections from a specific CFB team, set college to the \n name of that team. For example, if you want to only get NFL Draft information for \n draft picks from the Clemson Tigers Football Program, set college to Clemson.

\n\n

conference (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections from a specific CFB confrence, set conference to the abbreviation of that confrence. \n A list of CFBD API confrence abbreviations can be found in the conference_abbreviation column from \n the pandas DataFrame that is returned by calling cfbd_json_py.conferences.get_cfbd_conference_info().\n For example, if you want to only get NFL Draft information for \n draft picks that played in the Big 12, set confrence to B12.

\n\n

position (str, optional):\n Semi-Optional argument.\n If you only want NFL Draft selections who played a specific position, \n set position to that position's abbreviation. \n A list of CFBD API positions can be found in the position_abbreviation column from \n the pandas DataFrame that is returned by calling cfbd_json_py.draft.get_cfbd_nfl_positions().

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.draft import get_cfbd_nfl_draft_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get NFL Draft selections from the 2020 NFL Draft.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made by the\n    # 2020 Cincinnati Bengals.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made by the 2020 Cincinnati Bengals.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        nfl_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # Clemson Tigers football players.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving Clemson Tigers football players.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        college=\"Clemson\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # players who played in the Southeastern Confrence (SEC).\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving players who played in the Southeastern Confrence (SEC).\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        conference=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made\n    # where the selected player was a QB in college.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made where the selected player was a QB in college.\")\n    json_data = get_cfbd_nfl_draft_info(\n        api_key=cfbd_key,\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        position=\"QB\",\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get NFL Draft selections from the 2020 NFL Draft.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft.\")\n    json_data = get_cfbd_nfl_draft_info(season=2020)\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made by the\n    # 2020 Cincinnati Bengals.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made by the 2020 Cincinnati Bengals.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        nfl_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # Clemson Tigers football players.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving Clemson Tigers football players.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        college=\"Clemson\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made involving\n    # players who played in the Southeastern Confrence (SEC).\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made involving players who played in the Southeastern Confrence (SEC).\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        conference=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get NFL Draft selections from the 2020 NFL Draft made\n    # where the selected player was a QB in college.\n    print(\"Get NFL Draft selections from the 2020 NFL Draft made where the selected player was a QB in college.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_nfl_draft_info(\n        season=2020,\n        position=\"QB\",\n        return_as_dict=True\n    )\n    print(json_data)\n
\n\n

Returns

\n\n

A pandas DataFrame object with NFL Draft selection data, \nor (if return_as_dict is set to True) \na dictionary object with NFL Draft selection data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tnfl_team: str = None,\tcollege: str = None,\tconference_abv: str = None,\tposition: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.drives", "modulename": "cfbd_json_py.drives", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.drives.get_cfbd_drives_info", "modulename": "cfbd_json_py.drives", "qualname": "get_cfbd_drives_info", "kind": "function", "doc": "

Retrives a list of CFB drives from the CFBD API.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB drive information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB drive information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB drive data for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB drive data from games in that season, and that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB drive data for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB drive data from.

\n\n

offensive_team (str, optional):\n Optional argument.\n If you only want CFB drive data from a team, while they are on offense, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB drive data from.

\n\n

defensive_team (str, optional):\n Optional argument.\n If you only want CFB drive data from a team, while they are on defense,\n regardless if they are the home/away team,\n set team to the name of the team you want CFB drive data from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want CFB drive data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want CFB drive data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

offensive_conference_abv (str, optional):\n Optional argument.\n If you only want CFB drive data from games \n where the offensive team is from a specific confrenece,\n set conference_abv to the abbreviation \n of the conference you want CFB drive data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

defensive_conference_abv (str, optional):\n Optional argument.\n If you only want CFB drive data from games \n where the defensive team is from a specific confrenece,\n set conference_abv to the abbreviation \n of the conference you want CFB drive data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

ncaa_division (str, semi-optional):\n Semi-optional argument.\n By default, ncaa_division will be set to \"fbs\", \n short for the Football Bowl Subdivision (FBS), \n formerly known as D1-A (read as \"division one single A\"),\n the highest level in the NCAA football pyramid,\n where teams can scolarship up to 85 players \n on their football team soley for athletic ability, \n and often have the largest athletics budgets\n within the NCAA.

\n\n
Other valid inputs are:\n- \"fcs\": Football Championship Subdivision (FCS), \n    formerly known as D1-AA (read as \"division one double A\").\n    An FCS school is still in the 1st division of the NCAA,\n    making them elligable for the March Madness tournament,\n    but may not have the resources to compete at the FBS level\n    at this time. FCS schools are limited to 63 athletic scolarships\n    for football.\n- \"ii\": NCAA Division II. Schools in this and D3 are not\n    elligable for the March Madness tournament, \n    and are limited to 36 athletic scolarships for their football team.\n- \"iii\": NCAA Division III. The largest single division within the \n    NCAA football pyramid. \n    D3 schools have the distinction of being part of \n    the only NCAA division that cannot give out scolarships soley \n    for athletic ability.\n
\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.drives import get_cfbd_drives_info\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get CFB Drive data from the 2020 CFB season.\n    print(\"Get CFB Drive data from the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from week 10 of the 2020 CFB season.\n    print(\"Get CFB Drive data from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Cincinnati Bearcats\n    # Football Team.\n    print(\"Get CFB Drive data from games involving the 2020 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio Bobcats\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio Bobcats Football Team, when Ohio was on offense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        offensive_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio State Buckeyes\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        defensive_team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 12 games in the 2020 CFB season.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B12\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 10 (B1G) games in the 2020 CFB season,\n    # where the Big 10 team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        offensive_conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from  Mid-American Conference (MAC) games\n    # in the 2020 CFB season, where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        defensive_conference_abv=\"MAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Football Championship Subdivision (FCS) games\n    # in week 3 ofthe 2020 CFB season,\n    # where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        api_key=cfbd_key,\n        season=2020,\n        week=3,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get CFB Drive data from the 2020 CFB season.\n    print(\"Get CFB Drive data from the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from week 10 of the 2020 CFB season.\n    print(\"Get CFB Drive data from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Cincinnati Bearcats\n    # Football Team.\n    print(\"Get CFB Drive data from games involving the 2020 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio Bobcats\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio Bobcats Football Team, when Ohio was on offense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        offensive_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from games involving the 2020 Ohio State Buckeyes\n    # Football Team, when Ohio was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        defensive_team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 12 games in the 2020 CFB season.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        conference_abv=\"B12\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Big 10 (B1G) games in the 2020 CFB season,\n    # where the Big 10 team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        offensive_conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from  Mid-American Conference (MAC) games\n    # in the 2020 CFB season, where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        defensive_conference_abv=\"MAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB Drive data from Football Championship Subdivision (FCS) games\n    # in week 3 ofthe 2020 CFB season,\n    # where the MAC team was on offense.\n    print(\"Get CFB Drive data from games involving the 2020 Ohio State Buckeyes Football Team, when Ohio State was on defense.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=3,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_drives_info(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB drive data, \nor (if return_as_dict is set to True) \na dictionary object with CFB drive data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\toffensive_team: str = None,\tdefensive_team: str = None,\tconference_abv: str = None,\toffensive_conference_abv: str = None,\tdefensive_conference_abv: str = None,\tncaa_division: str = 'fbs',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games", "modulename": "cfbd_json_py.games", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.games.get_cfbd_games", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_games", "kind": "function", "doc": "

Retrives game schedule data from the CFBD API.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB game information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB game information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB game information for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB game data from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB game information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB game information from.

\n\n

home_team (str, optional):\n Optional argument.\n If you only want game information for a team, \n where that team was the home team in this season,\n set home_team to the name of the team you want game information for.

\n\n

away_team (str, optional):\n Optional argument.\n If you only want game information for a team, \n where that team was the away team in this season,\n set away_team to the name of the team you want game information for.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want game information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want game information from.

\n\n

ncaa_division (str, semi-optional):\n Semi-optional argument.\n By default, ncaa_division will be set to \"fbs\", \n short for the Football Bowl Subdivision (FBS), \n formerly known as D1-A (read as \"division one single A\"),\n the highest level in the NCAA football pyramid,\n where teams can scolarship up to 85 players \n on their football team soley for athletic ability, \n and often have the largest athletics budgets\n within the NCAA.

\n\n
Other valid inputs are:\n- \"fcs\": Football Championship Subdivision (FCS), \n    formerly known as D1-AA (read as \"division one double A\").\n    An FCS school is still in the 1st division of the NCAA,\n    making them elligable for the March Madness tournament,\n    but may not have the resources to compete at the FBS level\n    at this time. FCS schools are limited to 63 athletic scolarships\n    for football.\n- \"ii\": NCAA Division II. Schools in this and D3 are not\n    elligable for the March Madness tournament, \n    and are limited to 36 athletic scolarships for their football team.\n- \"iii\": NCAA Division III. The largest single division within the \n    NCAA football pyramid. \n    D3 schools have the distinction of being part of \n    the only NCAA division that cannot give out scolarships soley \n    for athletic ability.\n
\n\n

game_id (int, optional):\n Optional argument. \n If game_id is set to a game ID, get_cfb_betting_lines() will try to get \n game information just for that game ID.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_games\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get CFB games from the 2020 CFB season.\n    print(\"Get CFB games from the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from week 10 of the 2020 CFB season.\n    print(\"Get CFB games from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\n    print(\"Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\n    print(\"Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2021,\n        home_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2019,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2022 college football games where one or more teams competing\n    # was a Football Championship Subdivision team.\n    print(\"Get 2022 college football games where one or more teams competing was a Football Championship Subdivision team.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get game information for the\n    # 2021 American Athletic Confrence (AAC) Championship Game.\n    print(\"Get game information for the 2021 American Athletic Confrence (AAC) Championship Game.\")\n    json_data = get_cfbd_games(\n        api_key=cfbd_key,\n        season=2018,\n        game_id=401331162\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_games(\n        season=2020,\n        week=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get CFB games from the 2020 CFB season.\n    print(\"Get CFB games from the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from week 10 of the 2020 CFB season.\n    print(\"Get CFB games from week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_games(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\n    print(\"Get CFB games from the 2019 CFB season that involved the 2019 LSU Tigers.\")\n    json_data = get_cfbd_games(\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\n    print(\"Get 2021 Cincinnati Bearcats Football games where the Bearcats were the home team.\")\n    json_data = get_cfbd_games(\n        season=2021,\n        home_team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        season=2019,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\n    print(\"Get 2018 Ohio Bobcats Football games where the Bobcats were the away team.\")\n    json_data = get_cfbd_games(\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get 2022 college football games where one or more teams competing\n    # was a Football Championship Subdivision team.\n    print(\"Get 2022 college football games where one or more teams competing was a Football Championship Subdivision team.\")\n    json_data = get_cfbd_games(\n        season=2018,\n        away_team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get game information for the\n    # 2021 American Athletic Confrence (AAC) Championship Game.\n    print(\"Get game information for the 2021 American Athletic Confrence (AAC) Championship Game.\")\n    json_data = get_cfbd_games(\n        season=2018,\n        game_id=401331162\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_games(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football game information, \nor (if return_as_dict is set to True) \na dictionary object with college football game information.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\thome_team: str = None,\taway_team: str = None,\tconference_abv: str = None,\tncaa_division: str = 'fbs',\tgame_id: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_team_records", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_team_records", "kind": "function", "doc": "

Get a team, or multiple team's record (wins, losses, ties) for home games, away games, \nconfrence games, and the team's record for that season.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want CFB team records data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want CFB team records data for a specific team,\n set team to the name of the team you want CFB drive data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want CFB team records data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want CFB team records data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_team_records\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get CFB team records from the 2020 CFB season.\n    print(\"Get CFB team records from the 2020 CFB season.\")\n    json_data = get_cfbd_team_records(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams fielded by the University of Cincinnati.\n    print(\"Get team records from football teams fielded by the University of Cincinnati.\")\n    json_data = get_cfbd_team_records(\n        api_key=cfbd_key,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams that played in the Big 10 (B1G) Confrence\n    # in the 2017 CFB season\n    print(\"Get team records from football teams that played in the Big 10 (B1G) Confrence in the 2017 CFB season\")\n    json_data = get_cfbd_team_records(\n        api_key=cfbd_key,\n        season=2017,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_records(\n        season=2020,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get CFB team records from the 2020 CFB season.\n    print(\"Get CFB team records from the 2020 CFB season.\")\n    json_data = get_cfbd_team_records(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams fielded by the University of Cincinnati.\n    print(\"Get team records from football teams fielded by the University of Cincinnati.\")\n    json_data = get_cfbd_team_records(\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team records from football teams that played in the Big 10 (B1G) Confrence\n    # in the 2017 CFB season\n    print(\"Get team records from football teams that played in the Big 10 (B1G) Confrence in the 2017 CFB season\")\n    json_data = get_cfbd_team_records(\n        season=2017,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_records(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with CFB team records data, \nor (if return_as_dict is set to True)\na dictionary object with CFB team records data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_season_weeks", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_season_weeks", "kind": "function", "doc": "

Retrives a list of weeks that occured in a given CFB season.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want a list of weeks that occured in a given CFB season information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get a list of weeks that occured in a given CFB season information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_season_weeks\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get a list of weeks in the 2020 CFB season.\n    print(\"Get a list of weeks in the 2020 CFB season.\")\n    json_data = get_cfbd_season_weeks(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_season_weeks(\n        season=2020,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get a list of weeks in the 2020 CFB season.\n    print(\"Get a list of weeks in the 2020 CFB season.\")\n    json_data = get_cfbd_season_weeks(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_season_weeks(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with a list of valid weeks in a given CFB season, \nor (if return_as_dict is set to True)\na dictionary object with a list of valid weeks in a given CFB season.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_game_media_info", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_game_media_info", "kind": "function", "doc": "

Gets known media information for CFB games in a given CFB season.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB media information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB media information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB media information for non-regular season games, \n set season_type to \"postseason\".\n If you want both \"regular\" and \"postseason\" games retunred, \n set season_type to \"both\"\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB media information from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB media information for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB media information from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want media information from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want game information from.

\n\n

media_type (str, semi-optional):\n Semi-optional argument.\n If you only want game broadcast information for a specific type of broadcast,\n set this to the type of broadcast.

\n\n
Valid inputs are: \n- `all` (default): Returns all games, and all known broadcasters for those games.\n- `tv`: Returns all known TV broadcasters for CFB games in the requested timeframe.\n- `radio`: Returns all known radio broadcasters \n    for CFB games in the requested timeframe.\n- `web`: Returns all known web broadcasts (like ESPN+) \n    for CFB games in the requested timeframe.\n- `ppv`: Returns all known Pay Per View (PPV) broadcasts \n    for CFB games in the requested timeframe.\n- `mobile`: Returns all known broadcasters that only broadcasted \n    games on mobile devices (?)\n
\n\n

ncaa_division (str, semi-optional):\n Semi-optional argument.\n By default, ncaa_division will be set to \"fbs\", \n short for the Football Bowl Subdivision (FBS), \n formerly known as D1-A (read as \"division one single A\"),\n the highest level in the NCAA football pyramid,\n where teams can scolarship up to 85 players \n on their football team soley for athletic ability, \n and often have the largest athletics budgets\n within the NCAA.

\n\n
Other valid inputs are:\n- \"fcs\": Football Championship Subdivision (FCS), \n    formerly known as D1-AA (read as \"division one double A\").\n    An FCS school is still in the 1st division of the NCAA,\n    making them elligable for the March Madness tournament,\n    but may not have the resources to compete at the FBS level\n    at this time. FCS schools are limited to 63 athletic scolarships\n    for football.\n- \"ii\": NCAA Division II. Schools in this and D3 are not\n    elligable for the March Madness tournament, \n    and are limited to 36 athletic scolarships for their football team.\n- \"iii\": NCAA Division III. The largest single division within the \n    NCAA football pyramid. \n    D3 schools have the distinction of being part of \n    the only NCAA division that cannot give out scolarships soley \n    for athletic ability.\n
\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_game_media_info\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get a media information for the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for postseason games in the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for week 10 games in the 2020 CFB season.\n    print(\"Get a media information for week 10 games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\n    print(\"Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\n    print(\"Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"AAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games in the the 2020 CFB season.\n    print(\"Get all known radio broadcasters for games in the the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        media_type=\"radio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\n    print(\"Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        api_key=cfbd_key,\n        season=2020,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get a media information for the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for postseason games in the 2020 CFB season.\n    print(\"Get a media information for the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a media information for week 10 games in the 2020 CFB season.\n    print(\"Get a media information for week 10 games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\n    print(\"Get all known broadcasters for games played by the Ohio State Football Program in the the 2019 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\n    print(\"Get all known radio broadcasters for games played by teams within the American Athletic Confrence (AAC) in the the 2021 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        conference_abv=\"AAC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known radio broadcasters for games in the the 2020 CFB season.\n    print(\"Get all known radio broadcasters for games in the the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        media_type=\"radio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\n    print(\"Get all known broadcasters for Football Championship Subdivision (FCS) games in the 2020 CFB season.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        ncaa_division=\"fcs\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_media_info(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football media information, \nor (if return_as_dict is set to True) \na dictionary object with college football media information.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\tconference_abv: str = None,\tmedia_type: str = 'all',\tncaa_division: str = 'fbs',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_player_game_stats", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_player_game_stats", "kind": "function", "doc": "

Retrives player game stats for a given time frame.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB player game stats from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB player game stats.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB player game stats for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

For the following three variables, \nat least one must be set to a non-null variable when calling this function.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB player game stats from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB player game stats for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB player game stats from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want player game stats from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want stats from.

\n\n

stat_category (str, optional):\n Optional argument.\n If only want stats for a specific stat category, \n set this variable to that category.

\n\n
Valid inputs are:\n- `passing`\n- `rushing`\n- `receiving`\n- `fumbles`\n- `defensive`\n- `interceptions`\n- `punting`\n- `kicking`\n- `kickReturns`\n- `puntReturns`\n
\n\n

game_id (int, optional):\n Optional argument. \n If game_id is set to a game ID, get_cfbd_player_game_stats() will try to get \n player game stats just for that game ID.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_player_game_stats\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player game stats for week 10 of the 2020 CFB season.\n    print(\"Get player game stats for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get postseason player game stats for the 2020 CFB season.\n    print(\"Get postseason player game stats for the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\",\n        week=1\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\n    print(\"Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2018,\n        team=\"Alabama\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\n    print(\"Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get get passing stats from players who played in week 7 of the 2017 CFB season.\n    print(\"Get get passing stats from players who played in week 7 of the 2017 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2017,\n        week=7,\n        stat_category=\"pasing\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats from the 2021 Virbo Citrus Bowl, \n    # a bowl game that happened in the 2020 CFB season.\n    print(\"Get player game stats from the 2021 Virbo Citrus Bowl, a bowl game that happened in the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        api_key=cfbd_key,\n        season=2020,\n        game_id=401256199\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        week=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player game stats for week 10 of the 2020 CFB season.\n    print(\"Get player game stats for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get postseason player game stats for the 2020 CFB season.\n    print(\"Get postseason player game stats for the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        season_type=\"postseason\",\n        week=1\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\n    print(\"Get player game stats for the Alabma Crimson Tide Football Team for the 2018 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2018,\n        team=\"Alabama\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\n    print(\"Get player game stats for players of teams in the Atlantic Coast Conference (ACC) in the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        conference_abv=\"ACC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get get passing stats from players who played in week 7 of the 2017 CFB season.\n    print(\"Get get passing stats from players who played in week 7 of the 2017 CFB season.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2017,\n        week=7,\n        stat_category=\"passing\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game stats from the 2021 Virbo Citrus Bowl, \n    # a bowl game that happened in the 2020 CFB season,\n    # between the Aubrun Tigers, and the Northwestern Wildcats.\n    print(\"Get player game stats from the 2021 Virbo Citrus Bowl, \"+\n        \"a bowl game that happened in the 2020 CFB season between the Aubrun Tigers, and the Northwestern Wildcats.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        game_id=401256199\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_stats(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player game stats data, \nor (if return_as_dict is set to True) \na dictionary object with player game stats data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tseason_type: str = 'regular',\tweek: int = None,\tteam: str = None,\tconference_abv: str = None,\tstat_category: str = None,\tgame_id: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_player_advanced_game_stats", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_player_advanced_game_stats", "kind": "function", "doc": "

Retrives advanced game stats from the CFBD API.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.games import get_cfbd_player_advanced_game_stats\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, \n    # and the Oklahoma Sooners Football Program.\n    print(\"Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        api_key=cfbd_key,\n        game_id=401135278\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        api_key=cfbd_key,\n        game_id=401135278,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, \n    # and the Oklahoma Sooners Football Program.\n    print(\"Get advanced player stats for a 2019 CFB game between the LSU Tigers Football Program, and the Oklahoma Sooners Football Program.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        game_id=401135278\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_advanced_game_stats(\n        game_id=401135278,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with college football game information, \nor (if return_as_dict is set to True) \na dictionary object with college football game information.

\n", "signature": "(\tgame_id: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_live_scoreboard", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_live_scoreboard", "kind": "function", "doc": "

YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!\nTo view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tncaa_division: str = 'fbs',\tconference: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.games.get_cfbd_weather_info", "modulename": "cfbd_json_py.games", "qualname": "get_cfbd_weather_info", "kind": "function", "doc": "

YOU MUST BE SUBSCRIBED TO THE CFBD PATREON FOR THIS FUNCTION TO WORK!\nTo view the CFBD Patreon, visit https://www.patreon.com/collegefootballdata

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tncaa_division: str = 'fbs',\tgame_id: int = None,\tseason: int = None,\tweek: int = None,\tseason_type: str = 'regular',\tconference: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics", "modulename": "cfbd_json_py.metrics", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_predicted_ppa_from_down_distance", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_predicted_ppa_from_down_distance", "kind": "function", "doc": "

Given a down and distance, \nthis function will attempt to get the predicted\nPPA value for that down and distance, \nat every yard line possible for that down and distance.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

For this endpoint, \n[yardLine] is the number of yards from 1 (offense has the ball on their side, \nat their 1 yard line), to 99 \n(offense with the ball with a X and goal situation on the opponent's 1 yard line.

\n\n

Parameters

\n\n

down (int, mandatory):\n Mandatory argument.\n This is the down (a number between 1 and 4 in normal situations)\n for this play you want PPA for.

\n\n

distance (int, mandatory):\n Mandatory argument.\n This variable should be set to the number of yards between \n the line of scrimage (LOS), and the first down line on the field.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_predicted_ppa_from_down_distance\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get the predicted PPA for a 1st and 10 play, \n    # in every possible situation.\n    print(\"Get the predicted PPA for a 1st and 10 play, in every possible situation.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10,\n        api_key=cfbd_key\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10,\n        api_key=cfbd_key,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n\n    # Get the predicted PPA for a 1st and 10 play, \n    # in every possible situation.\n    print(\"Get the predicted PPA for a 1st and 10 play, in every possible situation.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_predicted_ppa_from_down_distance(\n        down=1,\n        distance=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with a calculated PPA from a dwon and distance, \nor (if return_as_dict is set to True) \na dictionary object with a calculated PPA from a dwon and distance.

\n", "signature": "(\tdown: int,\tdistance: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_team_season_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_team_season_ppa_data", "kind": "function", "doc": "

Allows you to get team PPA data, \nover an entire season,\nwith or without garbage time plays, \nfor a specificed team and/or time period.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want team PPA data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want team PPA data for a specific team,\n set team to the name of the team you want team PPA data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want team PPA data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want team PPA data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_team_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get team season PPA data for the 2020 CFB season.\n    print(\"Get team PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes, \n    # but exclude garbage time plays when making the PPA calculations.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes, but exclude garbage time plays when making the PPA calculations.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio State\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\n    print(\"Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B1G\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get team season PPA data for the 2020 CFB season.\n    print(\"Get team PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        team=\"Ohio State\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for the 2020 Ohio State Buckeyes, \n    # but exclude garbage time plays when making the PPA calculations.\n    print(\"Get team season PPA data for the 2020 Ohio State Buckeyes, but exclude garbage time plays when making the PPA calculations.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        team=\"Ohio State\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\n    print(\"Get team season PPA data for teams in the Big 10 (B1G) Conference in the 2020 CFB Season.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_ppa_data(\n        season=2020,\n        conference_abv=\"B1G\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with team season PPA data, \nor (if return_as_dict is set to True) \na dictionary object with a team season PPA data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\texclude_garbage_time: bool = False,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_team_game_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_team_game_ppa_data", "kind": "function", "doc": "

Allows you to get team PPA data, \nat a game level,\nwith or without garbage time plays, \nfor a specificed team and/or time period.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want team game PPA data information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get team game PPA data information.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load team game PPA data from games in that season, and in that week.

\n\n

team (str, optional):\n Optional argument.\n If you only want team game PPA data for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want team game PPA data from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want team game PPA data from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want team game PPA data from.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want team game PPA data for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_team_game_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get team PPA data for individual games within the 2020 CFB season.\n    print(\"Get team PPA data for individual games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for week 10 games within the 2020 CFB season.\n    print(\"Get team PPA data for week 10 games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for \n    # University of Cincinnati football games within the 2020 CFB season.\n    print(\"Get team PPA data for University of Cincinnati football games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season, but exclude plays that occur in garbage time.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season, but exclude plays that occur in garbage time.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for postseason games in the 2020 CFB season.\n    print(\"Get team PPA data for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get team PPA data for individual games within the 2020 CFB season.\n    print(\"Get team PPA data for individual games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for week 10 games within the 2020 CFB season.\n    print(\"Get team PPA data for week 10 games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for \n    # University of Cincinnati football games within the 2020 CFB season.\n    print(\"Get team PPA data for University of Cincinnati football games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for Southeastern Conference (SEC) \n    # games within the 2020 CFB season, but exclude plays that occur in garbage time.\n    print(\"Get team PPA data for Southeastern Conference (SEC) games within the 2020 CFB season, but exclude plays that occur in garbage time.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        conference_abv=\"SEC\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get team PPA data for postseason games in the 2020 CFB season.\n    print(\"Get team PPA data for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_team_game_ppa_data(\n        season=2020,\n        team=\"Cincinnati\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with team PPA data, \nor (if return_as_dict is set to True) \na dictionary object with team PPA data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\tconference_abv: str = None,\texclude_garbage_time: bool = False,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_player_game_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_player_game_ppa_data", "kind": "function", "doc": "

Allows you to get player PPA data, \nat a game level,\nwith or without garbage time plays, \nfor a specificed time period and/or team.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, semi-optional):\n Semi-Optional argument.\n Specifies the season you want player game PPA data information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get player game PPA data information.

\n\n

week (int, semi-optional):\n Semi-Optional argument.\n If week is set to an integer, this function will attempt \n to load player game PPA data from games in that season, and in that week.\n week and/or team must be set to a non-null value for this function \n to work.

\n\n

team (str, semi-optional):\n Semi-Optional argument.\n If you only want player game PPA data for players of a specific team, \n regardless if they are the home/away team,\n set team to the name of the team you want player game PPA data from.\n week and/or team must be set to a non-null value for this function \n to work.

\n\n

position (str, optional):\n Optional argument.\n If you only want player game PPA data for players of a specific position, \n set position to the position you want player game PPA data from.

\n\n

player_id (int, optional):\n Optional argument.\n If you only want PPA data for a specific player ID, \n set this variable to the player ID of the player you want PPA data from.

\n\n

play_threshold\n Optional argument.\n If you only want PPA data for players \n who touched the ball for X number of plays in a game,\n set play_threshold = x, where x is \n your specified minimum number of plays.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want player game PPA data for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_player_game_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player game PPA data for week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for players of the \n    # 2020 University of Cincinnati Football team.\n    print(\"Get player game PPA data for players of the 2020 University of Cincinnati Football team.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season, \n    # but exclude plays in garbage time.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, but exclude plays in garbage time.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        position=\"QB\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for week 10 of the 2020 CFB season,\n    # where a player touched the ball for at least 25 plays.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, where a player touched the ball for at least 25 plays.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        play_threshold=25\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data the 2020 Alabama Crimson Tide Football team, \n    # during their postseason.\n    print(\"Get player game PPA data the 2020 Alabama Crimson Tide Football team, during their postseason.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Alabama\",\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player game PPA data for week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for players of the \n    # 2020 University of Cincinnati Football team.\n    print(\"Get player game PPA data for players of the 2020 University of Cincinnati Football team.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for QBs who played in week 10 of the 2020 CFB season, \n    # but exclude plays in garbage time.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, but exclude plays in garbage time.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        position=\"QB\",\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data for week 10 of the 2020 CFB season,\n    # where a player touched the ball for at least 25 plays.\n    print(\"Get player game PPA data for week 10 of the 2020 CFB season, where a player touched the ball for at least 25 plays.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        play_threshold=25\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player game PPA data the 2020 Alabama Crimson Tide Football team, \n    # during their postseason.\n    print(\"Get player game PPA data the 2020 Alabama Crimson Tide Football team, during their postseason.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        team=\"Alabama\",\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_game_ppa_data(\n        season=2020,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player PPA data, \nor (if return_as_dict is set to True) \na dictionary object with player PPA data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tweek: int = None,\tteam: str = None,\tposition: str = None,\tplayer_id: int = None,\tplay_threshold: int = None,\texclude_garbage_time: bool = False,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_player_season_ppa_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_player_season_ppa_data", "kind": "function", "doc": "

Allows you to get player PPA data, \nat a season level,\nwith or without garbage time plays, \nfor a specificed time period and/or team.

\n\n

PPA is the CFBD API's equivalent metric to Expected Points Added (EPA).

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, semi-optional):\n Semi-Optional argument.\n Specifies the season you want player season PPA data information from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get player season PPA data information.

\n\n

team (str, semi-optional):\n Semi-Optional argument.\n If you only want player season PPA data for players of a specific team, \n regardless if they are the home/away team,\n set team to the name of the team you want player season PPA data from.\n week and/or team must be set to a non-null value for this function \n to work.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want player season PPA data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want player season PPA data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

position (str, optional):\n Optional argument.\n If you only want player season PPA data for players of a specific position, \n set position to the position you want player season PPA data from.

\n\n

player_id (int, optional):\n Optional argument.\n If you only want PPA data for a specific player ID, \n set this variable to the player ID of the player you want PPA data from.

\n\n

play_threshold\n Optional argument.\n If you only want PPA data for players \n who touched the ball for X number of plays in a game,\n set play_threshold = x, where x is \n your specified minimum number of plays.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_player_season_ppa_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player season PPA data for the 2020 CFB season.\n    print(\"Get player season PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 Ohio Bobcats Football Team.\n    print(\"Get player season PPA data for the 2020 Ohio Bobcats Football Team.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data for players who played on\n    # teams within the Southeastern Conference (SEC) for the\n    # 2020 CFB Season.\n    print(\"Get player season PPA data for players who played on teams within the Southeastern Conference (SEC) for the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from QBs in the 2020 CFB Season.\n    print(\"Get player season PPA data from QBs in the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511).\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511).\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        player_id=3915511\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511),\n    # but exclude plays that occured in garbage time.\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511), but exclude plays that occured in garbage time.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        player_id=3915511,\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 CFB Season,\n    # for players with at least 100 plays/touches.\n    print(\"Get player season PPA data from the 2020 CFB Season, for players with at least 100 plays/touches.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        play_threshold=100\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        api_key=cfbd_key,\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player season PPA data for the 2020 CFB season.\n    print(\"Get player season PPA data for the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 Ohio Bobcats Football Team.\n    print(\"Get player season PPA data for the 2020 Ohio Bobcats Football Team.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data for players who played on\n    # teams within the Southeastern Conference (SEC) for the\n    # 2020 CFB Season.\n    print(\"Get player season PPA data for players who played on teams within the Southeastern Conference (SEC) for the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from QBs in the 2020 CFB Season.\n    print(\"Get player season PPA data from QBs in the 2020 CFB Season.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511).\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511).\")\n    json_data = get_cfbd_player_season_ppa_data(\n        player_id=3915511\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from\n    # former Ohio State and LSU QB Joe Burrow (player ID #3915511),\n    # but exclude plays that occured in garbage time.\n    print(\"Get player season PPA data from former Ohio State and LSU QB Joe Burrow (player ID #3915511), but exclude plays that occured in garbage time.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        player_id=3915511,\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season PPA data from the 2020 CFB Season,\n    # for players with at least 100 plays/touches.\n    print(\"Get player season PPA data from the 2020 CFB Season, for players with at least 100 plays/touches.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        play_threshold=100\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_season_ppa_data(\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player PPA data, \nor (if return_as_dict is set to True) \na dictionary object with player PPA data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\tposition: str = None,\tplayer_id: int = None,\tplay_threshold: int = None,\texclude_garbage_time: bool = False,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_game_win_probability_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_game_win_probability_data", "kind": "function", "doc": "

Allows one to get win probabliity data for a given game ID.

\n\n

Parameters

\n\n

game_id (int, mandatory):\n Mandatory argument.\n This is the game ID for the game you want win probability data from,\n at the play-by-play level.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_game_win_probability_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get the win probablility data for a 2017 game between \n    # the University of Cincinnati and UConn (game ID #400941851).\n    print(\"Get the win probablility data for a 2017 game between the University of Cincinnati and UConn (game ID #400941851).\")\n    json_data = get_cfbd_game_win_probability_data(\n        api_key=cfbd_key,\n        game_id=400941851\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get the win probablility data for a 2023 game between \n    # the University of Duke and the University of Louisville (game ID #401525535).\n    print(\"Get the win probablility data for a 2023 game between the University of Duke and the University of Louisville (game ID #401525535).\")\n    json_data = get_cfbd_game_win_probability_data(\n        api_key=cfbd_key,\n        game_id=401525535\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_win_probability_data(\n        api_key=cfbd_key,\n        game_id=400941851,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get win probablility data for a 2017 game between \n    # the University of Cincinnati and UConn (game ID #400941851).\n    print(\"Get the win probablility data for a 2017 game between the University of Cincinnati and UConn (game ID #400941851).\")\n    json_data = get_cfbd_game_win_probability_data(\n        game_id=400941851\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get win probablility data for a 2023 game between \n    # the University of Duke and the University of Louisville (game ID #401525535).\n    print(\"Get the win probablility data for a 2023 game between the University of Duke and the University of Louisville (game ID #401525535).\")\n    json_data = get_cfbd_game_win_probability_data(\n        game_id=401525535\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_game_win_probability_data(\n        game_id=400941851,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with win probability data at the play-by-play level,\nor (if return_as_dict is set to True) \na dictionary object with win probability data at the play-by-play level.

\n", "signature": "(\tgame_id: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.metrics.get_cfbd_pregame_win_probability_data", "modulename": "cfbd_json_py.metrics", "qualname": "get_cfbd_pregame_win_probability_data", "kind": "function", "doc": "

Allows you to get pregame win probability data for games within a timeframe.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want pregame win probability data.

\n\n

week (int, optional):\n Optional argument.\n If week is set to an integer, this function will attempt \n to load CFB game data from games in that season, and in that week.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want pregame win probability data for a specific team,\n set team to the name of the team you want pregame win probability data from.

\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB game information for non-regular season games, \n set season_type to \"postseason\".\n If season_type is set to anything but \"regular\" or \"postseason\", \n a ValueError() will be raised.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.metrics import get_cfbd_pregame_win_probability_data\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get pregame win probabilities for games in the 2023 CFB season.\n    print(\"Get pregame win probabilities for games in the 2023 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2023\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games in week 10 of the 2021 CFB season.\n    print(\"Get pregame win probabilities for games in week 10 of the 2021 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\n    print(\"Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for postseason games in the 2020 CFB season.\n    print(\"Get pregame win probabilities for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        api_key=cfbd_key,\n        season=2023,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n# Get pregame win probabilities for games in the 2023 CFB season.\n    print(\"Get pregame win probabilities for games in the 2023 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2023\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games in week 10 of the 2021 CFB season.\n    print(\"Get pregame win probabilities for games in week 10 of the 2021 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\n    print(\"Get pregame win probabilities for games involving the 2021 Cincinnati Bearcats Football Team.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2021,\n        week=10\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get pregame win probabilities for postseason games in the 2020 CFB season.\n    print(\"Get pregame win probabilities for postseason games in the 2020 CFB season.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2020,\n        season_type=\"postseason\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_pregame_win_probability_data(\n        season=2023,\n        week=10,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with pregame win probability data, \nor (if return_as_dict is set to True) \na dictionary object with a pregame win probability data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players", "modulename": "cfbd_json_py.players", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.players.cfbd_player_search", "modulename": "cfbd_json_py.players", "qualname": "cfbd_player_search", "kind": "function", "doc": "

Given a string, search for players who's \nname matches that string in some capacity.

\n\n

Parameters

\n\n

search_str (int, mandatory):\n Mandatory argument.\n This is the name of the player you are trying to find.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

position (bool, semi-optional):\n Semi-optional argument.\n If you only want players from a specific position, \n set position to the position you want to find players from.

\n\n

team (bool, semi-optional):\n Semi-optional argument.\n If you only want players from a specific team, \n set team to the name of the team you want to find players from.

\n\n

season (bool, semi-optional):\n Semi-optional argument.\n If you only want players from a specific CFB season, \n set season to the season you want to find players from.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.players import cfbd_player_search\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get a list of every known \"Joe\" in the CFBD API.\n    print(\"Get a list of every known \"Joe\" in the CFBD API.\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"Joe\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".\n    print(\"Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"Joe B\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.\n    print(\"Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"Jim\",\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.\n    print(\"Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"A\",\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.\n    print(\"Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"Jim\",\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.\n    print(\"Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"Joe\",\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = cfbd_player_search(\n        api_key=cfbd_key,\n        search_str=\"Justin F\",\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get a list of every known \"Joe\" in the CFBD API.\n    print(\"Get a list of every known \"Joe\" in the CFBD API.\")\n    json_data = cfbd_player_search(\n        search_str=\"Joe\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".\n    print(\"Get a list of every known \"Joe\" in the CFBD API, who's last name starts with \"B\".\")\n    json_data = cfbd_player_search(\n        search_str=\"Joe B\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.\n    print(\"Get a list of every known \"Jim\" in the CFBD API, who happened to play with the University of Cincinnati Football Team at some point in their career.\")\n    json_data = cfbd_player_search(\n        search_str=\"Jim\",\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.\n    print(\"Get a list of every known player of the University of Cincinnati Football Team, that had the letter \"A\" in their name.\")\n    json_data = cfbd_player_search(\n        search_str=\"A\",\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.\n    print(\"Get a list of every known \"Jim\" in the CFBD API, who happened to play QB at some point in their career.\")\n    json_data = cfbd_player_search(\n        search_str=\"Jim\",\n        position=\"QB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.\n    print(\"Get a list of every known \"Joe\" in the CFBD API, who happened to play in the 2020 CFB sesason.\")\n    json_data = cfbd_player_search(\n        search_str=\"Joe\",\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = cfbd_player_search(\n        search_str=\"Justin F\",\n        season=2020,\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with a list of players who matched the search string, \nor (if return_as_dict is set to True) \na dictionary object with a list of players who matched the search string.

\n", "signature": "(\tsearch_str: str,\tapi_key: str = None,\tapi_key_dir: str = None,\tposition: str = None,\tteam: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_player_usage", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_player_usage", "kind": "function", "doc": "

Get player usage data (A.K.A., the percentages for how often a player touched the ball),\nfor a given season, at the season level, from the CFBD API.

\n\n

Parameters

\n\n

season (int, optional):\n Mandatory argument.\n Specifies the season you want player usage data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want player usage data for a specific team,\n set team to the name of the team you want player usage data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

position (str, optional):\n Semi-Optional argument.\n If you only want player usage data \n for players who played a specific position, \n set position to that position's abbreviation. \n A list of CFBD API positions can be found in the position_abbreviation column from \n the pandas DataFrame that is returned by calling cfbd_json_py.draft.get_cfbd_nfl_positions().

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want player usage data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want player usage data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

player_id (int, optional):\n Optional argument.\n If you only want player usage data for a specific player ID, \n set this variable to the player ID of the player you want player usage data from.

\n\n

exclude_garbage_time (bool, optional):\n Optional argument.\n If you want to filter out plays where the result of the game is largely decided,\n set exclude_garbage_time = True.\n Default behavior is that this variable is set to \n False when this function is called.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.players import get_cfbd_player_usage\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player usage data from the 2020 CFB season.\n    print(\"Get player usage data from the 2020 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data for the \n    # University of Cincinnati Bearcats Football Team, \n    # during the 2020 CFB season.\n    print(\"Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from players who \n    # primarily played running back (RB) in the 2020 CFB season.\n    print(\"Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2020,\n        position=\"RB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from players who played on \n    # Big 10 Confrence (B1G) teams during the 2020 CFB Season.\n    print(\"Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from \n    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), \n    # during the 2019 CFB season.\n    print(\"Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2019,\n        player_id=3915511\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from \n    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), \n    # during the 2019 CFB season, \n    # but filter out plays that occured in garbage time.\n    print(\"Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2019,\n        player_id=3915511,\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_usage(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"LSU\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player usage data from the 2020 CFB season.\n    print(\"Get player usage data from the 2020 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data for the \n    # University of Cincinnati Bearcats Football Team, \n    # during the 2020 CFB season.\n    print(\"Get player usage data for the University of Cincinnati Bearcats Football Team, during the 2020 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        season=2020,\n        team=\"Cincinnati\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from players who \n    # primarily played running back (RB) in the 2020 CFB season.\n    print(\"Get player usage data from players who primarily played running back (RB) in the 2020 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        season=2020,\n        position=\"RB\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from players who played on \n    # Big 10 Confrence (B1G) teams during the 2020 CFB Season.\n    print(\"Get player usage data from players who played on Big 10 Confrence (B1G) teams during the 2020 CFB Season.\")\n    json_data = get_cfbd_player_usage(\n        season=2020,\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from \n    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), \n    # during the 2019 CFB season.\n    print(\"Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        season=2019,\n        player_id=3915511\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player usage data from \n    # former LSU Tigers quarterback Joe Burrow (player ID #3915511), \n    # during the 2019 CFB season, \n    # but filter out plays that occured in garbage time.\n    print(\"Get player usage data from former LSU Tigers quarterback Joe Burrow (player ID #3915511), during the 2019 CFB season.\")\n    json_data = get_cfbd_player_usage(\n        season=2019,\n        player_id=3915511,\n        exclude_garbage_time=True\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_usage(\n        season=2020,\n        team=\"LSU\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with player usage data, \nor (if return_as_dict is set to True) \na dictionary object with player usage data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tconference_abv: str = None,\tposition: str = None,\tplayer_id: int = None,\texclude_garbage_time: bool = False,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_returning_production", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_returning_production", "kind": "function", "doc": "

Get data from the CFBD API \non how much returning production a team has going into a CFB season.

\n\n

Parameters

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

season (int, optional):\n Semi-optional argument. \n Specifies the season you want team PPA data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

team (str, optional):\n Semi-ptional argument.\n If you only want team PPA data for a specific team,\n set team to the name of the team you want team PPA data from.\n You MUST set season or team to a non-null value for \n this function to work. If you don't, a ValueError() \n will be raised.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want team PPA data from games \n involving teams from a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want team PPA data from.\n For a list of confrences, \n use the cfbd_json_py.conferences.get_cfbd_conference_info()\n function.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.players import get_cfbd_returning_production\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get returning production for teams who competed in the 2020 CFB season.\n    print(\"Get returning production for teams who competed in the 2020 CFB season.\")\n    json_data = get_cfbd_returning_production(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get historical returning production for the Ohio Bobcats Football Team.\n    print(\"Get historical returning production for the Ohio Bobcats Football Team.\")\n    json_data = get_cfbd_returning_production(\n        api_key=cfbd_key,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get returning production for the 2019 LSU Tigers.\n    print(\"Get returning production for the 2019 LSU Tigers.\")\n    json_data = get_cfbd_returning_production(\n        api_key=cfbd_key,\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.\n    print(\"Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.\")\n    json_data = get_cfbd_returning_production(\n        api_key=cfbd_key,\n        team=\"Maryland\",\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get returning production .\n    print(\"Get returning production for the 2019 LSU Tigers.\")\n    json_data = get_cfbd_returning_production(\n        api_key=cfbd_key,\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_returning_production(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"LSU\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get returning production for teams who competed in the 2020 CFB season.\n    print(\"Get returning production for teams who competed in the 2020 CFB season.\")\n    json_data = get_cfbd_returning_production(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get historical returning production for the Ohio Bobcats Football Team.\n    print(\"Get historical returning production for the Ohio Bobcats Football Team.\")\n    json_data = get_cfbd_returning_production(\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get returning production for the 2019 LSU Tigers.\n    print(\"Get returning production for the 2019 LSU Tigers.\")\n    json_data = get_cfbd_returning_production(\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.\n    print(\"Get returning production for Maryland, for seasons where Maryland is a member of the Big 10 (B1G) Conference.\")\n    json_data = get_cfbd_returning_production(\n        team=\"Maryland\",\n        conference_abv=\"B1G\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get returning production .\n    print(\"Get returning production for the 2019 LSU Tigers.\")\n    json_data = get_cfbd_returning_production(\n        season=2019,\n        team=\"LSU\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_returning_production(\n        season=2020,\n        team=\"LSU\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with returning production data, \nor (if return_as_dict is set to True) \na dictionary object with returning production data.

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_player_season_stats", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_player_season_stats", "kind": "function", "doc": "

Get player season stats, or the stats of players in a specific timeframe, from the CFBD API.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB player season stats from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB player season stats.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

team (str, optional):\n Optional argument.\n If you only want CFB player season stats for a team, \n regardless if they are the home/away team,\n set team to the name of the team you want CFB player season stats from.

\n\n

conference_abv (str, optional):\n Optional argument.\n If you only want player season stats from games \n involving teams a specific confrence, \n set conference_abv to the abbreviation \n of the conference you want stats from.

\n\n

start_week (int, semi-optional):\n Optional argument.\n If you only want player stats for a range of weeks, \n set start_week and end_week to \n the range of weeks you want season-level data for.

\n\n

end_week (int, semi-optional):\n Optional argument.\n If you only want player stats for a range of weeks, \n set start_week and end_week to \n the range of weeks you want season-level data for.

\n\n

NOTE: If the following conditions are True, a ValueError() \nwill be raised when calling this function:

\n\n
    \n
  • start_week < 0
  • \n
  • end_week < 0
  • \n
  • start_week != None and end_week == None (will be changed in a future version)
  • \n
  • start_week == None and end_week != None (will be changed in a future version)
  • \n
  • end_week < start_week
  • \n
  • end_week = start_week
  • \n
\n\n

season_type (str, semi-optional):\n Semi-optional argument.\n By defualt, this will be set to \"regular\", for the CFB regular season.\n If you want CFB media information for non-regular season games, \n set season_type to \"postseason\".\n If you want both regular and postseason stats, set season_type = \"both\".\n If season_type is set to anything but \"regular\", \"postseason\", or \"both\", \n a ValueError() will be raised.

\n\n

stat_category (str, optional):\n Optional argument.\n If only want stats for a specific stat category, \n set this variable to that category.

\n\n
Valid inputs are:\n- `passing`\n- `rushing`\n- `receiving`\n- `fumbles`\n- `defensive`\n- `interceptions`\n- `punting`\n- `kicking`\n- `kickReturns`\n- `puntReturns`\n
\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
import time\n\nfrom cfbd_json_py.players import get_cfbd_player_season_stats\n\n\ncfbd_key = \"tigersAreAwsome\"  # placeholder for your CFBD API Key.\n\nif cfbd_key != \"tigersAreAwsome\":\n    print(\"Using the user's API key declared in this script for this example.\")\n\n    # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.\n    print(\"Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season stats for teams who competed in \n    # the Southeastern Confrence (SEC) in the 2023 CFB season.\n    print(\"Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season stats for teams who competed in \n    # the Southeastern Confrence (SEC) in the 2023 CFB season,\n    # but only between weeks 1 and 5.\n    print(\"Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\",\n        start_week=1,\n        end_week=5\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get player season stats for the 2020 CFB season.\n    print(\"Get player season stats for the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get player season stats for \n    # the Ohio Bobcats Football team in the 2022 CFB season, \n    # but only use regular season games when calculating season stats.\n    print(\"Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2022,\n        team=\"Ohio\",\n        season_type=\"regular\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get passing stats for teams who competed in \n    # the Southeastern Confrence (SEC) in the 2023 CFB season.\n    print(\"Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2020,\n        conference_abv=\"SEC\",\n        stat_category=\"passing\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_season_stats(\n        api_key=cfbd_key,\n        season=2020,\n        team=\"LSU\",\n        stat_category=\"kicking\",\n        return_as_dict=True\n    )\n    print(json_data)\n\nelse:\n    # Alternatively, if the CFBD API key exists in this python environment,\n    # or it's been set by cfbd_json_py.utls.set_cfbd_api_token(),\n    # you could just call these functions directly, without setting the API key\n    # in the script.\n    print(\"Using the user's API key suposedly loaded into this python environment for this example.\")\n\n    # Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.\n    print(\"Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2020,\n        team=\"Ohio\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season stats for teams who competed in \n    # the Southeastern Confrence (SEC) in the 2023 CFB season.\n    print(\"Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2020,\n        conference_abv=\"SEC\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get player season stats for teams who competed in \n    # the Southeastern Confrence (SEC) in the 2023 CFB season,\n    # but only between weeks 1 and 5.\n    print(\"Get player season stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2020,\n        conference_abv=\"SEC\",\n        start_week=1,\n        end_week=5\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get player season stats for the 2020 CFB season.\n    print(\"Get player season stats for the 2020 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2020\n    )\n    print(json_data)\n    time.sleep(5)\n\n\n    # Get player season stats for \n    # the Ohio Bobcats Football team in the 2022 CFB season, \n    # but only use regular season games when calculating season stats.\n    print(\"Get player season stats for the Ohio Bobcats Football team in the 2020 CFB season, but only use regular season games when calculating season stats.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2022,\n        team=\"Ohio\",\n        season_type=\"regular\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # Get passing stats for teams who competed in \n    # the Southeastern Confrence (SEC) in the 2023 CFB season.\n    print(\"Get passing stats for teams who competed in the Southeastern Confrence (SEC) in the 2023 CFB season.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2020,\n        conference_abv=\"SEC\",\n        stat_category=\"passing\"\n    )\n    print(json_data)\n    time.sleep(5)\n\n    # You can also tell this function to just return the API call as\n    # a Dictionary (read: JSON) object.\n    print(\"You can also tell this function to just return the API call as a Dictionary (read: JSON) object.\")\n    json_data = get_cfbd_player_season_stats(\n        season=2020,\n        team=\"LSU\",\n        stat_category=\"kicking\",\n        return_as_dict=True\n    )\n    print(json_data)\n\n\n
\n\n

Returns

\n\n

A pandas DataFrame object with a list of players who matched the search string, \nor (if return_as_dict is set to True) \na dictionary object with a list of players who matched the search string.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tconference_abv: str = None,\tstart_week: int = None,\tend_week: int = None,\tseason_type: str = 'both',\tstat_category: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.players.get_cfbd_transfer_portal_data", "modulename": "cfbd_json_py.players", "qualname": "get_cfbd_transfer_portal_data", "kind": "function", "doc": "

Get player usage data (A.K.A., the percentages for how often a player touched the ball),\nfor a given season, from the CFBD API.

\n\n

Parameters

\n\n

season (int, mandatory):\n Required argument.\n Specifies the season you want CFB transfer portal data from.\n This must be specified, otherwise this package, and by extension\n the CFBD API, will not accept the request to get CFB transfer portal data stats.

\n\n

api_key (str, optional):\n Semi-optional argument. \n If api_key is null, this function will attempt to load a CFBD API key\n from the python environment, or from a file on this computer.\n If api_key is not null, this function will automatically assume that the\n inputted api_key is a valid CFBD API key.

\n\n

api_key_dir (str, optional):\n Optional argument.\n If api_key is set to am empty string, this variable is ignored.\n If api_key_dir is null, and api_key is null, \n this function will try to find a CFBD API key file in this user's home directory.\n If api_key_dir is set to a string, and api_key is null,\n this function will assume that api_key_dir is a directory, \n and will try to find a CFBD API key file in that directory.

\n\n

return_as_dict (bool, semi-optional):\n Semi-optional argument.\n If you want this function to return the data as a dictionary (read: JSON object), \n instead of a pandas DataFrame object,\n set return_as_dict to True.

\n\n

Usage

\n\n
\n
\n\n

Returns

\n\n

A pandas DataFrame object with transfer portal data, \nor (if return_as_dict is set to True) \na dictionary object with transfer portal data.

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays", "modulename": "cfbd_json_py.plays", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_data", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_data", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\toffensive_team: str = None,\tdefensive_team: str = None,\tconference_abv: str = None,\toffensive_conference_abv: str = None,\tdefensive_conference_abv: str = None,\tplay_type: int = None,\tncaa_division: str = 'fbs',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_play_types", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_play_types", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_stats", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_stats", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tteam: str = None,\tgame_id: int = None,\tathlete_id: int = None,\tstat_type_id: int = None,\tseason_type: str = 'regular',\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_pbp_stat_types", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_pbp_stat_types", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.plays.get_cfbd_live_pbp_data", "modulename": "cfbd_json_py.plays", "qualname": "get_cfbd_live_pbp_data", "kind": "function", "doc": "

\n", "signature": "(\tgame_id: int,\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.rankings", "modulename": "cfbd_json_py.rankings", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.rankings.get_cfbd_poll_rankings", "modulename": "cfbd_json_py.rankings", "qualname": "get_cfbd_poll_rankings", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings", "modulename": "cfbd_json_py.ratings", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_sp_plus_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_sp_plus_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_srs_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_srs_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: int = None,\tconferenece: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_sp_plus_conference_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_sp_plus_conference_ratings", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.ratings.get_cfbd_elo_ratings", "modulename": "cfbd_json_py.ratings", "qualname": "get_cfbd_elo_ratings", "kind": "function", "doc": "

\n", "signature": "(\tseason: int,\tapi_key: str = None,\tapi_key_dir: str = None,\tweek: int = None,\tseason_type: str = 'regular',\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.recruiting", "modulename": "cfbd_json_py.recruiting", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.recruiting.get_cfbd_player_recruit_ratings", "modulename": "cfbd_json_py.recruiting", "qualname": "get_cfbd_player_recruit_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\trecruit_classification: str = 'HighSchool',\tposition: str = None,\tstate: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.recruiting.get_cfbd_team_recruiting_ratings", "modulename": "cfbd_json_py.recruiting", "qualname": "get_cfbd_team_recruiting_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.recruiting.get_cfbd_team_recruiting_group_ratings", "modulename": "cfbd_json_py.recruiting", "qualname": "get_cfbd_team_recruiting_group_ratings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tstart_season: int = None,\tend_season: int = None,\tteam: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats", "modulename": "cfbd_json_py.stats", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.stats.get_cfbd_team_season_stats", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_team_season_stats", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tconference_abv: str = None,\tstart_week: int = None,\tend_week: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats.get_cfbd_advanced_team_season_stats", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_advanced_team_season_stats", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\texclude_garbage_time: bool = False,\tstart_week: int = None,\tend_week: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats.get_cfbd_advanced_team_game_stats", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_advanced_team_game_stats", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\tteam: str = None,\tweek: int = None,\topponent: str = None,\texclude_garbage_time: bool = False,\tseason_type: str = 'regular',\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.stats.get_cfbd_team_stat_categories", "modulename": "cfbd_json_py.stats", "qualname": "get_cfbd_team_stat_categories", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams", "modulename": "cfbd_json_py.teams", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_information", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_information", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tconference_abv: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_fbs_team_list", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_fbs_team_list", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_rosters", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_rosters", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tteam: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_talent_rankings", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_talent_rankings", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\tseason: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.teams.get_cfbd_team_matchup_history", "modulename": "cfbd_json_py.teams", "qualname": "get_cfbd_team_matchup_history", "kind": "function", "doc": "

\n", "signature": "(\tteam_1: str,\tteam_2: str,\tapi_key: str = None,\tapi_key_dir: str = None,\tmin_season: int = None,\tmax_season: int = None,\treturn_as_dict: bool = False):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls", "modulename": "cfbd_json_py.utls", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.utls.reverse_cipher_encrypt", "modulename": "cfbd_json_py.utls", "qualname": "reverse_cipher_encrypt", "kind": "function", "doc": "

NOT INTENDED TO BE CALLED BY THE USER!

\n\n

Implements a reverse cipher encription to a plain text string.

\n\n

Parameters

\n\n

plain_text_str (mandatory, str):\n The string you want to encrypt through reverse cipher encryption.

\n\n

Returns

\n\n

A string encrypted through reverse cipher encryption.

\n", "signature": "(plain_text_str: str):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls.reverse_cipher_decrypt", "modulename": "cfbd_json_py.utls", "qualname": "reverse_cipher_decrypt", "kind": "function", "doc": "

NOT INTENDED TO BE CALLED BY THE USER!

\n\n

Decrypts a string that was presumed to be encrypted by a reverse cipher encryption.

\n\n

Parameters

\n\n

encrypted_text_str (mandatory, str):\n The string you presume that is encrypted through reverse cipher encryption, \n that you want decrypted.

\n\n

Returns

\n\n

A decrypted string.

\n", "signature": "(encrypted_text_str: str):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls.get_cfbd_api_token", "modulename": "cfbd_json_py.utls", "qualname": "get_cfbd_api_token", "kind": "function", "doc": "

NOT INTENDED TO BE CALLED BY THE USER!

\n\n

If you've already set the API key using \ncfbd_json_py.utls.set_cfbd_api_token(),\nyou don't need to use this function.

\n\n

If the CFBD API key exists in the environment, \nor is in a file, this function retrives the CFBD API key, \nand returns it as a string.

\n\n

If this package is being used in a GitHub Actions action,\nset the key in the environment by \ncreating a repository secret nammed CFBD_API_KEY.

\n\n

Parameters

\n\n

api_key_dir (str, optional):\n Optional argument. If api_key_dir is set to a non-null string, \n set_cfbd_api_token() will attempt to save the key file in that directory,\n instead of this user's home directory.

\n\n

Returns

\n\n

A CFBD API key that exists within this python environment,\nor within this computer.

\n", "signature": "(api_key_dir: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.utls.set_cfbd_api_token", "modulename": "cfbd_json_py.utls", "qualname": "set_cfbd_api_token", "kind": "function", "doc": "

Sets the CFBD API key into a file that exists \neither in {home_dir}/.cfbd/cfbd_key.json, or in a custom directory.

\n\n

Parameters

\n\n

api_key (str, mandatory):\n The CFBD API key you have. \n DO NOT input Bearer {your CFBD API key},\n this package will take care of that for you.

\n\n

api_key_dir (str, optional):\n Optional argument. If api_key_dir is set to a non-null string, \n set_cfbd_api_token() will attempt to save the key file in that directory,\n instead of this user's home directory.

\n\n

Returns

\n\n

Nothing. \nThis function only sets up the API key file that this package can reference later.

\n", "signature": "(api_key: str, api_key_dir: str = None):", "funcdef": "def"}, {"fullname": "cfbd_json_py.venues", "modulename": "cfbd_json_py.venues", "kind": "module", "doc": "

\n"}, {"fullname": "cfbd_json_py.venues.get_cfbd_venues", "modulename": "cfbd_json_py.venues", "qualname": "get_cfbd_venues", "kind": "function", "doc": "

\n", "signature": "(\tapi_key: str = None,\tapi_key_dir: str = None,\treturn_as_dict: bool = False):", "funcdef": "def"}]; // mirrored in build-search-index.js (part 1) // Also split on html tags. this is a cheap heuristic, but good enough. diff --git a/pyproject.toml b/pyproject.toml index fab3b43..aec3c4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "cfbd_json_py" -version = "0.0.10" +version = "0.0.11" readme = "README.md" requires-python = ">=3.10" license = {text = "MIT"}