title: Why doesn't pandas allow a categorical column to be used in groupby?
body: <p>I would like to create a custom sorted DataFrame.  To do this I have used <code>pandas.Categorical()</code> however if I then use the result of this in a groupby <code>NAN</code> values are returned.</p>
  
  <pre><code># import the pandas module
  import pandas as pd
  
  # Create an example dataframe
  raw_data = {'Date': ['2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13','2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13', '2016-05-13'],
          'Portfolio': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B','B', 'B', 'B', 'C', 'C', 'C', 'C', 'C', 'C'],
          'Duration': [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3],
          'Yield': [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],}
  
  df = pd.DataFrame(raw_data, columns = ['Date', 'Portfolio', 'Duration', 'Yield'])
  
  df['Portfolio'] = pd.Categorical(df['Portfolio'],['C', 'B', 'A'])
  df=df.sort_values('Portfolio')
  
  dfs = df.groupby(['Date','Portfolio'], as_index =False).sum()
  
  print(dfs)
  
                          Date    Portfolio   Duration   Yield
  Date        Portfolio               
  13/05/2016  C           NaN     NaN         NaN        NaN
              B           NaN     NaN         NaN        NaN
              A           NaN     NaN         NaN        NaN
  </code></pre>
  
  <p>Why is this and how can I overcome this?</p>
  
  <p>Also <code>SettingWithCopyWarning</code> is raised is there a better idiom for Categorical?</p>