Having the following Python code, was trying to use pd.merge but seems that key columns requires to be identical. Trying to to something similar to SQL join with "like" operator from df.B with categories.Pattern.
UPDATE with better data example.
import pandas as pd
import numpy as np
df = pd.DataFrame([[1, 'Gas Station'], [2, 'Servicenter'], [5, 'Bakery good bread'], [58, 'Fresh market MIA'], [76, 'Auto Liberty aa1121']], columns=['A','B'])
Out[12]:
A B
0 1 Gas Station
1 2 Servicenter
2 5 Bakery good bread
3 58 Fresh market MIA
4 76 Auto Liberty aa1121
categories = pd.DataFrame([['Gasoline', 'Gas Station'], ['Gasoline', 'Servicenter'], ['Food', 'Bakery'], ['Food', 'Fresh market'], ['Insurance', 'Auto Liberty']], columns=['Category','Pattern'])
Out[13]:
Category Pattern
0 Gasoline Gas Station
1 Gasoline Servicenter
2 Food Bakery
3 Food Fresh market
4 Insurance Auto Liberty
Expected result is:
Out[14]:
A B Category
0 1 Gas Station Gasoline
1 2 Servicenter Gasoline
2 5 Bakery good bread Food
3 58 Fresh market MIA Food
4 58 Auto Liberty aa1121 Insurance
Appreciate your suggestions/feedback.