title: Matching columns using if statements
body: <p>I am trying to clean up typos in this dataset.</p>
  <p>Database of employee names</p>
  <pre><code>First    Last    Location   
  John     Smith   Calgary    
  John     Smith   Toronto 
  Joh      Smith   Toronto    
  Steph    Sax     Vancouver  
  Steph    Sa      Vancouver  
  Victor   Jones   Toronto
  Stacy    Lee     Markham
  Stac     Lee     Markham
  Stacy    Lee     Calgary
  </code></pre>
  <p>There are some typos, in columns in first and last name.  I tried to create an unique identifier and use a groupby statement to isolate likely typos.</p>
  <p>Likely typos I think would fall under this category
  Match</p>
  <ul>
  <li>if ID1 matches another ID1 and ID2 doesn't match</li>
  <li>if ID2 matches another ID2 and ID1 doesn't match</li>
  </ul>
  <p>This is my desired dataset of likely typos</p>
  <pre><code>First    Last    Location     ID1              ID2
  John     Smith   Toronto      JohnToronto      SmithToronto
  Joh      Smith   Toronto      JohToronto       SmithToronto
  Steph    Sax     Vancouver    StephVancouver   SaxVancouver  
  Steph    Sa      Vancouver    StephVancouver   SaVancouver    
  Stacy    Lee     Markham      StacyMarkham     LeeMarkham
  Stac     Lee     Markham      StacMarkham      LeeMarkham
  </code></pre>
  <p>This is the code I tried so far</p>
  <pre><code>df[&quot;ID1&quot;] = df[&quot;First&quot;] + df[&quot;Location&quot;]
  df[&quot;ID2&quot;] = df[&quot;Last&quot;] + df[&quot;Location&quot;]
  
  m1 = df.groupby('ID1')['ID2'].transform('nunique').gt(1)
  m2 = df.groupby('ID2')['ID1'].transform('nunique').gt(1)
  
  out = df[m1|m2]
  </code></pre>
  <p>EDIT: full code, that isn't working.  It isn't filtering out for matching in ID2 but not matching in ID1.  Not picking up Stacy Lee from Markham...</p>
  <pre><code>   data = {'First':['John', 'John', 'Joh', 'Steph','Steph','Victor','Stacy','Stac','Stacy'],
      'Last':['Smith','Smith','Smith','Sax','Sa','Jones','Lee','Lee','Lee'],
       'Location':['Caglary','Toronto','Toronto','Vancouver','Vancouver','Toronto','Markham','Markahm','Calgary']}
  </code></pre>
  <p>Create DataFrame</p>
  <pre><code>df10 = pd.DataFrame(data)
  
  df10[&quot;ID1&quot;] = df10[&quot;First&quot;] +df10[&quot;Location&quot;]
  df10[&quot;ID2&quot;] = df10[&quot;Last&quot;] + df10[&quot;Location&quot;]
  
  m1 = df10.groupby('ID1')['ID2'].transform('nunique').gt(1)
  m2 = df10.groupby('ID2')['ID1'].transform('nunique').gt(1)
  
  out = df10[m1|m2]
  </code></pre>