I have two data source:
df1 = pd.DataFrame({'a': [1, 2, 3, 4]})
df2 = pd.DataFrame({'b': [
'Some text 11.',
'Good 2 number',
'Other 33 not valid',
'4 is good too even with 7'
]})
df1 look like
a
0 1
1 2
2 3
3 4
and the df2 looks like
b
0 Some text 11.
1 Good 2 number
2 Other 33 not valid
3 4 is good too even with 7
My goal is merge them if number from the column df1.a
exists in any position in the column df2.b
, but only exact number.
so the result should be:
a b
2 Good 2 number
4 4 is good too even with 7
I can modify the solution on string contains but looks very complicated. In the real data the both source has more than 20k records.