I have a dataframe which i created from merging one column from 7 different excel file. Below is the code i used:
import pandas as pd
import glob
my_excel_files = glob.glob(r"C:\Users\.........\*.xlsx")
total_dataframe = pd.DataFrame()
for file in my_excel_files:
new_df = df['Comments']
total_dataframe = pd.concat([total_dataframe, new_df], axis=1) # Puts together all Comments columns
As you can see from the code i grab the 'Comments' column from each excel and put them together into a new df, the only issue is i want to be able to add the filename into the column name so i know which column comes from which excel file, all of them are just called 'Comments' right now. So ideally one of the column headers would be 'Comments (first_response.xlsx)'