title: Match data between 2 pandas data frame and extract the matching value of another column in Python
body: <p>I have two pandas data frames. </p>
  
  <pre><code>df1 :
       ACNo       Product
  1   12340       100% Hot Care
  2   23867       Auction5
  3   98372       Edition
  4   09837       Diet Parameter
  5   54332       Load
  
  df2 :
      ProdDetail                          AttrName
  1   12345.567                           Age Confirmation
  2   Model1 Count\100% Hot Care          Recipe
  3   123445\Handle                       Improve
  4   Diet Edition\Parameter              Amount
  </code></pre>
  
  <p>I want to do a lookup of Product column from df1 on ProdDetail column of df2 and add AttrName column in df1 with the respective values. The string could be at any position in ProdDetails, basically similar to wildcard function in excel. If string appears in ProdDetail of df2, I want to pull the respective AttrName. The result df1 data frame should look like this</p>
  
  <pre><code>        ACNo        Product             AttrName
  1       12340       100% Hot Care       Recipe  
  2       23867       Auction5            N/A
  3       98372       Edition             Amount
  4       09837       Diet Parameter      N/A
  5       54332       Load                N/A
  </code></pre>
  
  <p>Could anyone, please help me out with this in python? I have tried multiple ways but not able to find the solution. I saw a similar post but it was in R, could not find in Python. Below is one of the way I tried</p>
  
  <pre><code>ip=df1['Product']
  def lookup_prod(ip):
        return df2[(df2['ProdDetail'].str.contains(ip, na=False))]['AttrName']
  df1['AttrName'] = data.apply(lambda row: lookup_prod(row['ProdDetails']), axis=1)
  
  df1 = pd.DataFrame({'ACNo': ['12340', '23867', '98372', '09837', '54332'],
                      'Product': ['100% Hot Care', 'Auction5', 'Edition', 'Diet Parameter', 'Load']})
  
  df2 = pd.DataFrame({'ProdDetail': [12345.567, r'Model1 Count\100% Hot Care',
                                     r'123445\Handle',  r'Diet Edition\Parameter'],
                      'AttrName': ['Age Confirmation', 'Recipe' , 'Improve',  'Amount']})
  </code></pre>