I have two dataframes table1 and table2:
table1
table2
I want to compare table1 with table2 and return miss rows from each other of table 1 and table 2.
I have two dataframes table1 and table2:
table1
table2
I want to compare table1 with table2 and return miss rows from each other of table 1 and table 2.
You can do:
only_in_1 = table1.merge(table2.assign(key=1), how='left')
only_in_1 = only_in_1[pd.isna(only_in_1['key'])].drop('key', axis=1)
import pandas as pd
import numpy as np
df1 = table1
df2 = table2
df_inner = df1.merge(df2, on = ['A', 'B', 'C'], how = 'inner')
df_outer = df1.merge(df2, on = ['A', 'B', 'C'], how = 'outer')
df_inner['label'] = np.ones(len(df_inner))
df = df_outer.merge(df_inner, on = ['A', 'B', 'C'], how = 'outer')
df = df[df['label'].isna()]
df = df.drop(['label'], axis = 1)