I am stuck in finding a common key stored in 2 different substings of 2 different dataframes and then output a 3rd column:
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'Name':['John','Michael','Dan','George', 'Adam'], 'Code1':['AAA OO','BBB UU','JJ',np.nan,'II']})
df2 = pd.DataFrame({'Second Name':['Smith','Cohen','Moore','Kas', 'Faber'], 'code2':['UU HHH','AAA GGG',np.nan , 'TT II', np.nan]})
The expected output:
I have done my research....... and the question is really similar to this one: How to merge pandas on string contains?. However here the key has a single item, my example has 2 items in both keys.