0

i wanted to join 2 csv files inorder for this result:

file1.csv

A  B  C
1  xx zz
2  zx x
3  id    

file2.csv

A  B  C
1  bc ux
5  zz xo
6  sf 

output.csv

A  B  C
1  xx zz
2  zx x
3  id 
5  zz  xo
6  sf

I used the following code but I got duplicate results such as row '1' coming twice as I have done 'outer join', i want to remove duplicates such that file1.csv content remains and file2.csv duplicate is removed.

    df1= pd.read_csv(r'file1.csv')
    df2=pd.read_csv(r'file2.csv')
    df =pd.merge(df1, df2, on='A', how='outer')

t j6789
  • 11
  • 1

0 Answers0