title: searching a word in the column pandas dataframe python
body: <p>I have two text columns and I would like to find whether a word from one column is present in another. I wrote the below code, which works very well, but it detects if a word is present anywhere in the string. For example, it will find "ha" in "ham". I want to use regex expression instead, but I am stuck. I came across this <a href="https://stackoverflow.com/questions/5319922/python-check-if-word-is-in-a-string">post</a> and looked at the second answer, but I haven't been able to modify it for my purpose. I would like to do something similar. </p>
  
  <p>I would appreciate help and/or any pointers</p>
  
  <pre><code>d = {'emp': ['abc d. efg', 'za', 'sdfadsf '], 'vendor': ['ABCD enterprise', 'za industries', '' ]}
  df = pd.DataFrame(data=d)
  df['clean_empy_name']=df["emp"].str.lower().str.replace('\W', ' ')
  
  def check_subset(vendor, employee):
      s = []
      for n in employee.split():
        # n=" " + n +"[^a-zA-Z\d:]"
        if ((str(n) in vendor.lower()) &amp; (len(str(n))&gt;1)):
          s.append(n)
      return s
  
  check_subset("ABC-xy 54", "54 xy")
  
  df['emp_name_find_in_vendor'] = df.apply(lambda row: check_subset(row['vendor'],row['clean_empy_name']), axis=1)
  df
  </code></pre>
  
  #########update 2
  
  <p>i updated my dataframe as below</p>
  
  <pre><code>d = {'emp': ['abc d. efg', 'za', 'sdfadsf ','abc','yuma'], 'vendor': ['ABCD enterprise', 'za industries', '','Person Vue\Cisco','U OF M CONTLEARNING' ]}
  df = pd.DataFrame(data=d)
  df['clean_empy_name']=df["emp"].str.lower().str.replace('\W', ' ')
  </code></pre>
  
  <p>I used code provided by first answer and it fails</p>
  
  <ol>
  <li>in case of <code>'Person Vue\Cisco'</code> it throws the error <code>error: bad escape \c</code>. If i remove \ in <code>'Person Vue\Cisco'</code>, code runs fine</li>
  <li>in case of <code>'U OF M CONTLEARNING'</code> it return <code>u</code> and <code>m</code> when clearly they are not a match </li>
  </ol>