Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

PREVIOUS NEXT
Code Example
Python :: connect mongodb with python 
Python :: django admin create project 
Python :: pandas difference between rows in a column 
Python :: sort and reverse list in python 
Python :: take first 10 row while reading csv python 
Python :: vscode python workding directory 
Python :: load python file in jupyter notebook 
Python :: pytorch version python command 
Python :: Publish Image msg ros python 
Python :: video capture opencv and multiprocessing 
Python :: array of objects in python 
Python :: python fibonacci function 
Python :: plot neural network keras 
Python :: How to count a specific number in a python list? 
Python :: calculate perimeter of rectangle in a class in python 
Python :: add list to end of list python 
Python :: python check if string contains substring 
Python :: how to add captcha in django forms 
Python :: perform_update serializer django 
Python :: how to add array in python 
Python :: task timed out after 3.00 seconds aws lambda python 
Python :: pandas dataframe add two columns int and string 
Python :: cv2 check if image is grayscale 
Python :: how to plot kmeans centroids 
Python :: python stack data structure 
Python :: count no of nan in a 2d array python 
Python :: if a list has a string remove 
Python :: len in python 
Python :: print colored text to console python 
Python :: dataframe of one row 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =