title: How to combine Dataframe of sets by checking intersection of 2 columns
body: <p>I'm trying to combine a Dataframe of sets by checking 2 columns</p>
  <p>This is my dataframe, the data inside every cell is python set()</p>
  <pre><code>import pandas as pd
  
  df = pd.DataFrame()
  df['COMPARE0'] = [set([1,2,3]),set([3,4,5]),set([6,7]),set([10,11]),set([12,13])]
  df['COMPARE1'] = [set(['a','b','c']),set(['d','e']),set(['c','f']),set(['g','h']),set(['h','i'])]
  df['GET0'] = [set(['aaa']),set(['bbb']),set(['ccc','ddd']),set(['efg','hii']),set(['efg','hiii'])]
  df['GET1'] = [set(['000']),set(['111']),set(['222']),set(['333','444']),set(['555'])]
  </code></pre>
  <p><strong>Input:</strong></p>
  <p><a href="https://i.stack.imgur.com/wUyyV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wUyyV.jpg" alt="enter image description here" /></a></p>
  <p>I would like to combine all rows based on set intersection result of COMPARE0 and COMPARE1</p>
  <p>If any intersection is found, then combine the all
  columns</p>
  <p><strong>Desired Output:</strong></p>
  <p><a href="https://i.stack.imgur.com/A3ovK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A3ovK.jpg" alt="enter image description here" /></a></p>
  <p>I'm using set() at the moment, but can be lists as well</p>
  <p>Any help is kindly appreciated, thankyou.</p>