title: How to convert an M x M pandas DataFrame into an N X 2 Dataframe?
body: <p>I have a pandas DataFrame like below:</p>
  <pre><code>df = pd.DataFrame({&quot;type&quot;: [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;],
                     &quot;A&quot;: [0, 0, 12],
                     &quot;B&quot;: [1, 3, 0],
                     &quot;C&quot;: [0, 1, 1]}
  )
  </code></pre>
  <p>I want to transform this to a DataFrame that is N X 2, where I concatenate the column and <code>type</code> values with <code>&quot; - &quot;</code> as delimiter. The output should look like this:</p>
  <pre><code>pair    value
  A - A   0
  A - B   0
  A - C   12
  B - A   1
  B - B   3
  B - C   0
  C - A   0
  C - B   1
  C - C   1
  </code></pre>
  <p>I don't know if there is a name for what I want to accomplish (I thought about pivoting but I believe that is something else), so that didn't help me in googling the solution for this. How to solve this problem efficiently?</p>