Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

remove common rows in two dataframes pandas

In [1]: import pandas as pd
df_1 = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]})
df_2 = pd.DataFrame({"A":["foo", "bar", "foo", "bar"], "B":[1,0,1,0], "C":["A","B","A","B"]})

In [2]: df = pd.concat([df_1, df_2])

In [3]: df
Out[3]: 
     A  B  C
0  foo  0  A
1  foo  1  A
2  foo  1  B
3  bar  1  A
0  foo  1  A
1  bar  0  B
2  foo  1  A
3  bar  0  B

In [4]: df.drop_duplicates(keep=False)
Out[4]: 
     A  B  C
0  foo  0  A
2  foo  1  B
3  bar  1  A
Comment

PREVIOUS NEXT
Code Example
Python :: k fold cross validation from scratch python 
Python :: google sheet api python 
Python :: add item to tuple python 
Python :: create new dataframe from existing data frame python 
Python :: django models 
Python :: python how to check if a dictionary key exists 
Python :: python random choices weights 
Python :: python check if string or list 
Python :: re.search() python 
Python :: sort lexo python 
Python :: how to replace string in python 
Python :: python3 format leading 0 
Python :: python zip files 
Python :: walrus operator python 3.8 
Python :: python counter 
Python :: pandas fillna 
Python :: install python ubuntu 
Python :: get type name python 
Python :: drop dataframe columns 
Python :: Python how to search in string 
Python :: how to check uppercase in python 
Python :: python close a socket 
Python :: python console install package 
Python :: How to show variable in Jupyter 
Python :: matplotlib.pyplot 
Python :: how to join basename and directory in python os 
Python :: assert in python 
Python :: python loop with index 
Python :: how to make a random question generator in python 
Python :: assert keyword in python 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =