I have a list of csv files I need to open, convert to DataFrames and then save the DataFrames using the same name as the csv file. I can successfully open the csv files but cannot seem to get the DataFrame named correctly.
csv_file_1 = ['X_test_cat']
for f_name in csv_file_1:
dir_beg = 'C:\\Users\\jsawjsaw1\\Documents\\Python\\'
end_dir = '.csv'
f_name = pd.read_csv(dir_beg+f_name+end_dir)
I expect to get a pandas DataFrame named X_test_cat. Instead I get a DataFrame named f_name. FYI - csv_file_1 will eventually have many file names and thus the reason for creating the list. Also, the above code does successfully open the csv file named X_test_cat.csv. I just can't seem to name the DataFrame X_test_cat. Thanks.