-1

I would like to compare the two daraframes based on key(branch) and also planning to remove the records based on key which are not matching from the both datasets.

Prasad
  • 79
  • 1
  • 4
  • Where is your code? What did you try so far? Your question seems to be about returning the intersection of two Dataframes. If so, then at least give a starting point from your side. The way your question is formatted at the moment one could not even directly import `df1` and `df2` into some notebook / ipython to quickly help. – daniel451 Feb 03 '20 at 02:58
  • Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – daniel451 Feb 03 '20 at 03:01
  • @daniel451 i am able get the record which are not matching from the both dataframes using below command diff_df = df1.merge(df2, on=['branch'], how='outer') , can you please tell me how i can delete the record which are not matching from both dataframes separately. – Prasad Feb 03 '20 at 17:39

1 Answers1

0

I think you want an inner merge

df1.merge(df2, on='branch', how='inner')

Kenan
  • 13,156
  • 8
  • 43
  • 50