I have a dataframe df1:
id1 id2
a1 b1
c1 d1
e1 d1
g1 h1
and df2:
id value
a1 10
b1 9
c1 7
d1 11
e1 12
g1 5
h1 8
I want to keep rows from df1 only if their values from value column in df2 differ (gap) no higher than 1. So desired output is:
id1 id2
a1 b1
e1 d1
row c1 d1 was removed since gap between 7 and 11 is higher than 1. same thing with g1 h1. How to do that?