INNER CODE UNIT · Python
req_prem_stats
mhaythornthwaite/Football_Prediction_Project · 01_api_data_request.py:181
def req_prem_stats(start_index, end_index):
for i in fixtures_clean.index[start_index:end_index]:
if math.isnan(fixtures_clean['Home Team Goals'].iloc[i]) == False:
fix_id = str(fixtures_clean['Fixture ID'].iloc[i])
fixture_raw = get_api_data(base_url, '/statistics/fixture/' + fix_id + '/')
fixture_sliced = slice_api(fixture_raw, 34, 2)
save_api_output('prem_game_stats_json_files/' + fix_id, fixture_sliced)
#req_prem_stats(288, 300)
#----- AUTOMATING MISSING DATA COLLECTION -----
#in this section we will search through our exisiting database (prem_game_stats_json_files folder) and request the game data of any missing games that have been played since we last requested data.
#listing the json data already collected
existing_data_raw = listdir('prem_game_stats_json_files/')