I have d1 and d2 and I want to merge the two by ID column. However, the ID and ID2 are not exactly match. Instead, ID is the first 8 digit of ID2 (sometimes it can be the first 6 digit, or sometimes it can be one or two digit different).
I understand that I can pre-process ID2 to keep only the first 8 digit. However, I cannot handle all the situations.
I wonder is there an advanced way to merge through regular expression for fuzzy match? say, if the first 6 digits match, then merge?
d1=pd.DataFrame({'ID':['00846U10','01381710'],
'count':[100,200]})
d2=pd.DataFrame({'ID2':['00846U101','013817101','02376R102'],
'value':[1,5,6]})