title: How to create a square dataframe/matrix given 3 columns - Python
body: <p>I am struggling to figure out how to develop a square matrix given a format like </p>
  
  <pre><code>a a 0
  a b 3
  a c 4
  a d 12
  b a 3 
  b b 0
  b c 2
  ...
  </code></pre>
  
  <p>To something like:</p>
  
  <pre><code>  a b c d e
  a 0 3 4 12 ... 
  b 3 0 2 7 ... 
  c 4 3 0 .. .
  d 12 ...  
  e . .. 
  </code></pre>
  
  <p>in pandas. I developed a method which I thinks works but takes forever to run because it has to iterate through each column and row for every value starting from the beginning each time using for loops. I feel like I'm definitely reinventing the wheel here. This also isnt realistic for my dataset given how many columns and rows there are. Is there something similar to R's cast function in python which can do this significantly faster? </p>