title: pandas pivot_table and value_counts different results
body: <p>So I have the following situation. I use pd.value_counts() and get, for example, the following Series:</p>
  
  <pre><code>A 50
  B 30
  C 15
  D 10
  </code></pre>
  
  <p>Then I do pd.pivot_table() (to understand whether X or Y is the reason) and get a sum across columns and get the following table: </p>
  
  <pre><code>  X   Y  Sum
  A 10  20 30
  B  5  10 15
  C  3   7 10
  D 35  15 50
  </code></pre>
  
  <p>As you can see, the "Sum" value of the pivot_table is different to the value_counts Series. You can also notice that <strong>the values are simply in incorrect order</strong>. Why is that and how can I fix it?</p>
  
  <p>I've checked and concluded that the pivot table provides wrong values, but I can't find the reason for that, nor a fix.</p>
  
  <p><strong>UPDATE:</strong> added file <a href="https://vk.com/doc165991992_495073144" rel="nofollow noreferrer">dataa.csv</a>, here is my code:</p>
  
  <pre><code>dataa['class'].value_counts()
  
  temp = dataa.pivot_table(values='ones', columns='xname', index='class', aggfunc=np.sum)
  temp['sum'] = temp.sum(axis=1)
  </code></pre>