title: Pandas: Pivot table without sorting index and columns
body: <p>I'm trying to pivot data in a way so that the index and columns of the resulting table aren't automatically sorted. An example of the data might be:</p>
  
  <pre><code>X   Y   Z
  
  1   1   1
  3   1   2
  2   1   3
  4   1   4
  
  1   2   5
  3   2   6
  2   2   7
  4   2   8
  </code></pre>
  
  <p>The data is interpreted as an X, Y and Z axis. The pivotted result should look like this:</p>
  
  <pre><code>X   1   3   2   4
  Y
  1   1   2   3   4
  2   5   6   7   8
  </code></pre>
  
  <p>Instead the result looks like this, where the index and columns are sorted, and the data accordingly:</p>
  
  <pre><code>X   1   2   3   4
  Y
  1   1   3   2   4
  2   5   7   6   8
  </code></pre>
  
  <p>At this point I have lost information about the order in which the measurements were taken. For example say that I would plot the row at Y=1, with X as the X axis and the data value on the Y axis. </p>
  
  <p><a href="http://imgur.com/iTx2sgf" rel="nofollow">This would result in the figures in this picture.</a> On the right is how I would like the data to be plotted. Does anyone have an idea how to prevent pandas from sorting the index and columns when pivotting a table?</p>