I have some Python Pandas code to read in multiple files from the same folder. I would like to include the individual file names too.My code, which works fine, is pulling in all the data I need. However I need to include the filename as a separate column too. I'm having a bit of a brain freeze here. Can anyone help? ;
import pandas as pd
import glob
path =r'C:\my_file_path\Misc'
allFiles = glob.glob(path + "/*.csv")
list_ = []
for file_ in allFiles:
df = pd.read_csv(file_, index_col=None, dtype=str, header=0)
list_.append(df)
frame = pd.concat(list_, axis=0, irnore_index = TRUE)