Вот что я хотел бы предложить, сначала извлекая значения из таблицы 2, а затем объединяя этот преобразованный DataFrame с таблицей 1 по интересующим переменным:
Сначала я воспроизвожу ваш пример:
import pandas as pd
import re
# reproducing table 1
df1 = pd.DataFrame({"Location": ["MAB", "MEB"],
"Type" : ["Ant", "Ant"],
"Supplier":["A","B"],
"ID": ["A123","A123"],
"Serial": ["456/56","456/56"]})
# then table 2
df = pd.DataFrame({"Location": ["MAB+MEB", "MAB+MEB", "MAB+MEB"],
"Type": ["Ant", "Ant", "Ant"],
"Supplier": ["A/B", "A/B","A/B"],
"ID": ["A123", "A123/B123", "A123/B123"],
"Serial":['456/56','456/56','456/56'],
"values_rand":[1,2,3]})
# First I split the column I am interested in based on regexp you can tweak according
# to what you want:
r = re.compile(r"[a-zA-Z0-9]+")
df['Supplier'], df["ID"], df["Location"] = df['Supplier'].str.findall(r),\
df['ID'].str.findall(r), \
df['Location'].str.findall(r)
table2 = pd.merge(df['Supplier'].explode().reset_index(),
df["ID"].explode().reset_index(),on="index", how="outer")
table2 = pd.merge(table2, df["Location"].explode().reset_index(),
on="index", how="outer")
table2 = pd.merge(table2, df.loc[:,["Type","Serial",
"values_rand"]].reset_index(), on="index",how="left")
result = (pd.merge(table2,df1, on=['Location' , 'Supplier' , 'ID' , 'Serial',"Type"])
.drop(columns="index"))
Результат
Supplier ID Location Type Serial values_rand
0 A A123 MAB Ant 456/56 1
1 A A123 MAB Ant 456/56 2
2 A A123 MAB Ant 456/56 3
3 B A123 MEB Ant 456/56 1
4 B A123 MEB Ant 456/56 2
5 B A123 MEB Ant 456/56 3
Надеюсь, это поможет