0

Having two dataframes (df1 and df2) which have multiple categorical data columns (Country, City, Postcode) and one with quantitative data, how can I see all the rows which are in df1 but not in df2?

Both dataframes are not necassarily sorted in the same way. The Index is just a serial.

Bishonen_PL
  • 1,400
  • 4
  • 18
  • 31
  • Can you [edit](https://stackoverflow.com/posts/50701531/edit) with some example data? – jpp Jun 05 '18 at 13:39
  • take a look here: https://stackoverflow.com/questions/17095101/outputting-difference-in-two-pandas-dataframes-side-by-side-highlighting-the-d – H.J. Meijer Jun 05 '18 at 13:43

1 Answers1

1

You can using merge

df1.merge(df2.assign(onlydf1=1),on=['yourcategorydate'],how='left').loc[lambda x :x['onlydf1'].isnull(),:]
BENY
  • 317,841
  • 20
  • 164
  • 234
  • worked right off the bat. Thank you! I was already going the route of creating an index out of all the relevant columns and then using the 'difference' function which then needed to be used in 'index.isin', creating quite the code mess. Thanks again! – Bishonen_PL Jun 05 '18 at 13:55