title: Pandas to mark both if cell value is a substring of another
body: <p>A column with short and full form of people names, I want to unify them, if the name is a part of the other name. e.g. &quot;James.J&quot; and &quot;James.Jones&quot;, I want to tag them both as &quot;James.J&quot;.</p>
  <pre><code>data = {'Name': [&quot;Amelia.Smith&quot;,
  &quot;Lucas.M&quot;,
  &quot;James.J&quot;,
  &quot;Elijah.Brown&quot;,
  &quot;Amelia.S&quot;,
  &quot;James.Jones&quot;,
  &quot;Benjamin.Johnson&quot;]}
  
  df = pd.DataFrame(data)
  </code></pre>
  <p>I can't figure out how to do it in Pandas. So only a xlrd way, with similarity ratio by SequenceMatcher (and sort it manually in Excel):</p>
  <pre><code>import xlrd
  from xlrd import open_workbook,cellname
  import xlwt
  from xlutils.copy import copy 
  
  workbook = xlrd.open_workbook(&quot;C:\\TEM\\input.xlsx&quot;)
  
  old_sheet = workbook.sheet_by_name(&quot;Sheet1&quot;)
  
  from difflib import SequenceMatcher
  
  wb = copy(workbook) 
  sheet = wb.get_sheet(0) 
  
  for row_index in range(0, old_sheet.nrows):
  
      current = old_sheet.cell(row_index, 0).value
      previous = old_sheet.cell(row_index-1, 0).value
      sro = SequenceMatcher(None, current.lower(), previous.lower(), autojunk=True).ratio()
  
      if sro &gt; 0.7:
          sheet.write(row_index, 1, previous)
          sheet.write(row_index-1, 1, previous)
  
  wb.save(&quot;C:\\TEM\\output.xls&quot;)
  </code></pre>
  <p>What's the nice Pandas way to do it/ Thank you.</p>
  <p><a href="https://i.stack.imgur.com/F4l94.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F4l94.png" alt="enter image description here" /></a></p>