title: Creating an interaction matrix in python
body: <p>Can someone tell me how to generate an interaction matrix from a dataframe as follows?</p>
  
  <p>Input:</p>
  
  <pre><code>    cd1 = [True, False, True, False, False]
      cd2 = [False, True, True, False, False]
      cd3 = [True, False, False, True, True]
      df = pd.DataFrame({"cd1":cd1, "cd2": cd2, "cd3": cd3})
  </code></pre>
  
  <p>I want an output that looks like this </p>
  
  <pre><code>   cd1 cd2 cd3
  cd1 2   1   1
  cd2 1   2   0
  cd3 1   0   3
  </code></pre>