title: Pandas: If substring is in string, return value of adjacent cell
body: <p>I currently have the following working code: </p>
  
  <pre><code>for i,gram in enumerate(df['Unigram']):
      for j,word in enumerate(df1['Keyword']):
        if df.ix[i,'Unigram'] in df1.loc[j,'Keyword']:
          df.ix[i,'Cost'] += df1.ix[j,'Cost']
  </code></pre>
  
  <p>But it takes a good while for large data sets. Is there a more efficient method of going about this? I've heard that Pandas DataFrames prefer not to be looped, but am not sure of the best approach. A working solution would be able to account for multiple matches.</p>
  
  <p>Thanks in advance!</p>