Skip to content

Instantly share code, notes, and snippets.

@Hasil-Sharma
Created September 22, 2017 23:18
Show Gist options
  • Save Hasil-Sharma/921320b07ca03fb94ab4c25f0c5d5fc4 to your computer and use it in GitHub Desktop.
Save Hasil-Sharma/921320b07ca03fb94ab4c25f0c5d5fc4 to your computer and use it in GitHub Desktop.
Finding records which are in one DataFrame (df1) and not in other DataFrame (df2)
import pandas as pd
df1['marker'] = 1
joined = pd.merge(df1, df2, on = ['column'], how = 'left')
# Required columns are the ones with marker as NaN
df1 = joined[pd.isnull(joined['marker'])][df1.columns]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment