Answers for "Comparison of two csv file and output with differences?"

0

Comparison of two csv file and output with differences?

import pandas as pd

df1 = pd.read_csv('old.csv')
df2 = pd.read_csv('new.csv')

df1['flag'] = 'old'
df2['flag'] = 'new'

df = pd.concat([df1, df2])

dups_dropped = df.drop_duplicates(df.columns.difference(['flag']), keep=False)
dups_dropped.to_csv('update.csv', index=False)
Posted by: Guest on July-18-2021

Code answers related to "Comparison of two csv file and output with differences?"

Python Answers by Framework

Browse Popular Code Answers by Language