INNER CODE UNIT · Python
read_json_as_pd_df
mhaythornthwaite/Football_Prediction_Project · 01_api_data_request.py:64
def read_json_as_pd_df(json_data, json_data_path='', orient_def='records'):
output = pd.read_json(json_data_path + json_data, orient=orient_def)
return output
#---------------------------- REQUESTING BASIC DATA ---------------------------
base_url = 'https://v2.api-football.com/'
def req_prem_fixtures_id(season_code, year=YEAR_str):
#request to the api for the data
premier_league_fixtures_raw = get_api_data(base_url, f'/fixtures/league/{season_code}/')
#cleaning the data in preparation for loading into a dataframe
premier_league_fixtures_sliced = slice_api(premier_league_fixtures_raw, 33, 2)
#saving the clean data as a json file