Looked at other similar questions, but none has the use case I have. I have multiple files with the same format and no header
file1
id, value
1, 100
2, 150
...
file2
10, 500
11, 510
....
I would like to "merge" them to have
id, value
1, 100
2, 150
...
10, 500
11, 510
...
tried merge, append, concat but couldn't achieve the end result I am looking for.
df2 = pd.DataFrame(columns=['id','value'])
df2.columns = ['id','value']
for file_name in os.listdir(work_dir):
df1 = pd.read_csv(work_dir+'/'+file_name, header=None)
df1.columns = ['id','value']
df2 = pd.merge(df2,df1, on ='id')
Or any other suggestion to load multiple files in to a data frame appreciated. I do have another data frame coming from a db will be merged same way so merge is a question too.