I have some csv files that they have different columns , I should merge this files into one file, here is my code:
import os, glob
import pandas as pd
path = ""
all_files = glob.glob(os.path.join(path, "*.csv"))
df_from_each_file = (pd.read_csv(f, sep=',') for f in all_files)
df_merged = pd.concat(df_from_each_file, ignore_index=True, axis=1)
df_merged.to_csv( "merged.csv")
This code indicates the columns by numbers not their names! What should I do for saving columns names in merged file too?
Thanks for your helps