title: Pandas pivot table gives "FutureWarning: Sorting because non-concatenation axis is not aligned"
body: <p>I have the following DataFrame:</p>
  
  <pre><code>df = pd.DataFrame({'category':['A', 'B', 'C', 'C'], 
                     'bar':[2, 5, float('nan'), float('nan')]})
  </code></pre>
  
  <p>And then I have just one line of code, where I'm trying to apply two aggregation functions on a column in my DataFrame, grouped by values in another column:</p>
  
  <pre><code>df.pivot_table('bar', 'category', aggfunc=['median', 'count'])
  </code></pre>
  
  <p>For some reason, it gives me the following warning:</p>
  
  <blockquote>
    <p>FutureWarning: Sorting because non-concatenation axis is not aligned.
    A future version of pandas will change to not sort by default. To
    accept the future behavior, pass 'sort=False'. To retain the current
    behavior and silence the warning, pass 'sort=True'.</p>
  </blockquote>
  
  <p>From what I can understand about this warning, it concerns "concat()" or "append()" methods. I called neither of these, so I can only assume that one of the two is used implicitly somewhere inside the "pivot_table()" method. I'd be happy to pass the "sort" parameter to silence the warning, but I don't see the way of doing that if the method is called implicitly.</p>
  
  <p>I ran some tests on this example, and it looks like the warning appears only when all three of the following conditions are met:</p>
  
  <p>1) there's at least one group in the values that get aggregated that consists entirely of missing values;</p>
  
  <p>2) there are at least two aggregation functions;</p>
  
  <p>3) one of the aggregation functions is "count()".</p>
  
  <p>My working theory at the moment is that the two aggregation functions can't agree on how many rows the resulting pivot table should have. The "count()" function puts zeroes in all groups that consist entirely of missing values. But the other functions ignore such groups entirely, so the respective rows are simply missing from the pivot table when "count()" is not present. However, when "count()" is present, it forces the other functions to not ignore these groups, and creates NaN values in respective cells.</p>
  
  <p>This result works fine for me, I can use it, but I don't like leaving warnings unattended. Thoughts on what can be done about it?</p>