May-26-2020, 01:34 PM
Hi guys,
I am struggling to get the pd.concat function to merge (or append) two csv files. Each file has 4 x columns with the same type of data. My code is:
Any ideas please? I can send the test.csv files if needed.
I am struggling to get the pd.concat function to merge (or append) two csv files. Each file has 4 x columns with the same type of data. My code is:
import pandas as pd a = pd.read_csv('test.csv') b = pd.read_csv('test1.csv') merged=pd.concat([a,b],axis = 0, ignore_index = True, sort='False') merged.to_csv('merged_file.csv')I've tried various versions of this as well as :
merged=a.append(b,sort=False)The best I can get is for df 'b' to be put alongside 'a' and not at the end. Sometimes columns are also mixed up.
Any ideas please? I can send the test.csv files if needed.