My code uses pandas to extract information from an excel sheet. I created a function to read and extract what I need and then I set it as two variables so I can work the data.
But the start of my code seems a bit messy. Is there a way to rewrite it?
file_locations = 'C:/Users/sheet.xlsx' def process_file(file_locations): file_location = file_locations df = pd.read_excel(fr'{file_location}') wagon_list = df['Wagon'].tolist() weight_list = df['Weight'].tolist() It seems stupid to have a variable with the file destination and then set the file_location for pandas inside my function as the variable. I'm not sure if I could use file_location as the variable outside and inside the function I would call file_location = file_location.
Thanks for any input!
def process_file(file_location):?