I struggle with finding the correct logic a lot of the time. So I program with a sledgehammer instead of a scalpel. I am trying to get better. I just changed the extract data to your code.
At the bottom of the program I put a print statement in to check the data in xx to make sure the data structure and actual data is correct. It's not part of the program just a way of looking at xx.
print(xx) and check the printout in the ide gitbash.
def extract_horse_data(): horses_name.append( xx[horse_count][18]) for i in range(105) horses_info.append(xx[horse_count][i]) print(horses_info[18]) # just print here to make sure the horse names were being accessed correctly. Won't be in final program horse_single_race_info.append(horses_info) def load_track_to_Handi(): my_tracklabel= Label(root, text =" ", fg= "#F50808", font = ("sans_serif" , 16)).place(x=380, y=430) read_csvfile_into_array() global track_abrev global race_number global xx global horses_name global horse_saddle global hcount global horse_count global horse_array global horse_single_race_info global horses_info global horse_data horse_array = np.arange(2100).reshape(20,105) #if fileFound ==True: horse_data = {} horses_info = [] horse_single_race_info = [] horse_saddle = [] horses_name = [] hcount = 0 with open( 'C://guis/f_racefiles/'+ track_abrev + '.csv' , 'r') as race_file: df = pd.read_csv(race_file, header =None) xx = df.iloc[ :, 0: 105 ].values #READ FILE AND PULL OUT HORSES AND HORSE INFO FOR SELECTED RACE AND TRACK for horse_count in range(0,len(xx)): if int(xx[horse_count][1])== int(race_number): horses_info.clear() extract_horse_data() #load_horse_data() hcount+=1 get_scratches() #the following is where I start creating factors and where I printed out the 9 data elements checking my work as I go along. def trnr_jockey(counter): trainer_win_curmeet = (horse_single_race_info[counter][6]) / (horse_single_race_info[counter][5]) race_processed.append(trainer_win_curmeet) jockey_win_curmeet = round(((horse_single_race_info[counter][8]) / (horse_single_race_info[counter][7])) * 100, 2) race_processed.append(jockey_win_curmeet) trainer_Win_Pvyr = round(((horse_single_race_info[counter][10]) / (horse_single_race_info[counter][9])) * 100, 2) race_processed.append(trainer_Win_Pvyr) jockey_Win_Pvyr = round(((horse_single_race_info[counter][12]) / (horse_single_race_info[counter][11])) * 100, 2) race_processed.append(jockey_Win_Pvyr) trainer_Win_Cyr = round(((horse_single_race_info[counter][14]) / (horse_single_race_info[counter][13])) * 100, 2) race_processed.append(trainer_Win_Cyr ) jockey_Win_Cyr = round(((horse_single_race_info[counter][16]) / (horse_single_race_info[counter][15 ])) * 100, 2) race_processed.append(jockey_Win_Cyr) # set horses name, morning line, fold year def name_mornline_foldyr(counter): morning_line = horse_single_race_info[counter][17] race_processed.append(morning_line) horse_name = horse_single_race_info[counter][18] race_processed.append(horse_name) fold_yr = horse_single_race_info[counter][19] race_processed.append(fold_yr) #print(horse_single_race_info) #PROCESS HORSES INFOR TO GET FACTORS def process_race(scratched_list): global race_processed global counter race_processed = [] individual_horse_data = {} counter = 0 for i in range(hcount): # need to change this so can cycle through trnr_jockey(counter) name_mornline_foldyr(counter) counter+=1 print(race_processed)at tyhe get_scratches a windo opens, horses are scratched if they need be and then program is sent to the def process_race(scratched_list):
At the bottom of the program I put a print statement in to check the data in xx to make sure the data structure and actual data is correct. It's not part of the program just a way of looking at xx.
print(xx) and check the printout in the ide gitbash.