📜  两个csv文件的比较和输出有什么不同? - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:49.442000             🧑  作者: Mango

代码示例1
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)