0

I have two data frames which I am trying to merge based on matching values of few columns - Amount, Name, Year, Month.

df3 = pd.merge(df1,df2, left_on=['Name1','Year1','Month1','Amount1'], 
                        right_on=['Name2','Year2','Month2','Amount2'])

I want to incorporate the condition such that a variance of 6 months and a variance of 1000$ is allowed This means - Besides, the exact matching, matching should even occur if there is a difference of at most 6 months between Month1 and Month2. Similarly, matching should also occur if the amount differ by at most 1000$. Year and Name should always have exact matches.

mechanical_meat
  • 155,494
  • 24
  • 217
  • 209
ComplexData
  • 1,061
  • 4
  • 14
  • 33
  • 1
    [Possible duplicate](http://stackoverflow.com/questions/13636848/is-it-possible-to-do-fuzzy-match-merge-with-python-pandas) – ako Jul 19 '16 at 04:48
  • @ako I have to basically do it on numbers. Month is a number between 1 to 12, and then Amount is certain number. The post suggested by you is used for matching strings. – ComplexData Jul 19 '16 at 17:09

0 Answers0