title: Pandas: How to groupby combinations of column elements to indicate co-occurrence based on the values of a different column?
body: <p>I have a pandas dataframe of the form <strong>df</strong>,</p>
  
  <pre><code>Batch_ID    Product_ID
     1            A
     1            B
     1            C
     2            B
     2            B
     2            C
     2            C
     3            B
     3            B
     3            C
     4            C
     4            D
     5            D
  </code></pre>
  
  <p>I would like to get an edge list from this, essentially a new dataframe <strong>edge_list_df</strong> (which I cant then convert to  networkx object) of the form,</p>
  
  <pre><code>Source       Target         Weight
    A             B             1.0
    A             C             1.0
    A             D             0.0
    B             C             3.0
    B             D             0.0
    C             D             1.0
  </code></pre>
  
  <p>Note that I have given a number of different possibilities in the example to ensure my question is clear. For instance, the counter does not increase two times even though for Batch_ID=2 the B-C combination occurs twice.</p>
  
  <p>What is the most efficient way to achieve this?</p>