Convert an nxn matrix to a pandas dataframe
<p>I have an n by n data in csv in the following format</p>

<pre><code>-   A   B   C   D
A   0   1   2   4
B   2   0   3   1
C   1   0   0   5
D   2   5   4   0
...
</code></pre>

<p>I would like to read it and convert to a 3D pandas dataframe in the following format:</p>

<pre><code>Origin Dest Distance
A      A    0
A      B    1
A      C    2
</code></pre>

<p>...</p>

<p>What is the best way to convert it? In the worst case, I'll write a for loop to read each line and append the transpose of it but there must be an easier way. Any help would be appreciated.</p>