I try to find a solution to update a DataFrame (df2) with one row from another DataFrame (df1) if the string from df1 contains string from df2
Examples of the DataFrames:
df1 = {
'file_ident': ['553f995', 'd76eb4f', 'bebb72eed'],
'fname': ['first_file', 'no_name', 'try_out']}
df2 = {
'id': [1, 2, 3, 4],
'sname': ['is_first_file', 'have_no_name', 'example1', 'example2']}
Now I want to add column df['file_ident'] from df1 to df2 if df1['fname'] contains the pattern from d2['sname']
In python I would try to iterate between to lists in a for loop:
>>> name = 'is_first_file'
>>> search = 'first_file'
>>> print(re.search(search, name))
<re.Match object; span=(3, 13), match='first_file'>
I try different ways with df1.apply(...), lambda etc. but ether I get errors or a empty dataframe
regards