title: pandas str.contains match against multiple strings and get the matched values
body: <p>in the below example, i am able to match a pandas column containing text data against multiple collection of strings. The output will only tell me whether any part of the <code>df.col1</code> cell contains one of the elements from the collection. it will not tell me which one! I am interested in getting exactly that (the string matched or better still its positional location in the collection array)</p>
  
  <pre><code>words = ['dog', 'monkey']
  pat = "|".join(map(re.escape, words))
  
  df = pd.DataFrame({'col1':['lion bites dog','dog bites monkey','monkey bites man','man bites apple']})
  df.loc[df.col1.str.contains(pat),'col1']
  </code></pre>
  
  <p>the reason why i need to know which string from the collection (words above) was matched is because each element of the collection could be mapped to a numeric value. like</p>
  
  <pre><code>words_dict = {'dog':'1', 'monkey':'2'}
  </code></pre>
  
  <p>i can perhaps try <code>df.map(dict)</code>but in the actual case, the collection is stored in a <code>pandas dataframe</code> </p>
  
  <pre><code>words_df = pd.DataFrame({1:['dog'], 2:['monkey']})
  </code></pre>
  
  <p>i can think of a rather circuitous solution of checking for each element in the collection iteratively but that seems to be highly inefficient, if the number of elements in the collection is large.</p>
  
  <p>edit//</p>
  
  <p>the desired output can be either:</p>
  
  <pre><code>[0,0,1,NaN] or ['dog','dog','monkey',False]
  </code></pre>