title: "No numeric types to aggregate" after groupby and mean
body: <p>I'm dealing with time series and try to write function to calculation monthly average of data. Here are some function for prepare:</p>
  
  <pre><code>import datetime
  import numpy as numpy
  def date_range_0(start,end):
  
      dates = [start + datetime.timedelta(days=i) 
              for i in range((end-start).days+1)]
      return numpy.array(dates)
  def date_range_1(start,days):
      #days should be an interger
  
      return date_range_0(start,start+datetime.timedelta(days-1))
  
  x=date_range_1(datetime.datetime(2015, 5, 17),4)
  </code></pre>
  
  <p>x, the output is a simple time list:</p>
  
  <pre><code>array([datetime.datetime(2015, 5, 17, 0, 0),
     datetime.datetime(2015, 5, 18, 0, 0),
     datetime.datetime(2015, 5, 19, 0, 0),
     datetime.datetime(2015, 5, 20, 0, 0)], dtype=object)
  </code></pre>
  
  <p>Then I learn groupby function from <a href="http://blog.csdn.net/youngbit007/article/details/54288603" rel="noreferrer">http://blog.csdn.net/youngbit007/article/details/54288603</a>
  I have tried one example in website above and it works fine:</p>
  
  <pre><code>df = pandas.DataFrame({'key1':date_range_1(datetime.datetime(2015, 1, 17),5),
                'key2': [2015001,2015001,2015001,2015001,2015001],
                'data1': 1+0.1*numpy.arange(1,6)
          })
  df
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>   data1    key1    key2
  0   1.1 2015-01-17  2015001
  1   1.2 2015-01-18  2015001
  2   1.3 2015-01-19  2015001
  3   1.4 2015-01-20  2015001
  4   1.5 2015-01-21  2015001
  </code></pre>
  
  <p>and</p>
  
  <pre><code>grouped=df['data1'].groupby(df['key2'])
  grouped.mean()
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>key2
  2015001    0.2
  Name: data1, dtype: float64
  </code></pre>
  
  <p>Then I try my own example:</p>
  
  <pre><code>datedat=numpy.array([date_range_1(datetime.datetime(2015, 1, 17),5),1+0.1*numpy.arange(1,6)]).T
  months = [day.month for day in datedat[:,0]]
  years = [day.year for day in datedat[:,0]]
  datedatF = 
  pandas.DataFrame({'key1':datedat[:,0],'key2':list((numpy.array(years)*1000 +numpy.array(months))),'data1':datedat[:,1]})
  datedatF
  </code></pre>
  
  <p>which generated</p>
  
  <pre><code>   data1    key1    key2
  0   1.1 2015-01-17  2015001
  1   1.2 2015-01-18  2015001
  2   1.3 2015-01-19  2015001
  3   1.4 2015-01-20  2015001
  4   1.5 2015-01-21  2015001
  </code></pre>
  
  <p>Note this is exactly the very same table as above! so far so good. Then I run:</p>
  
  <pre><code>grouped2=datedatF['data1'].groupby(datedatF['key2'])
  grouped2.mean()
  </code></pre>
  
  <p>it throw out this:</p>
  
  <pre><code>   ---------------------------------------------------------------------------
  DataError                                 Traceback (most recent call last)
  &lt;ipython-input-170-f0d2bc225b88&gt; in &lt;module&gt;()
    1 grouped2=datedatF['data1'].groupby(datedatF['key2'])
  ----&gt; 2 grouped2.mean()
  
  /root/anaconda3/lib/python3.6/site-packages/pandas/core/groupby.py in     mean(self, *args, **kwargs)
     1017         nv.validate_groupby_func('mean', args, kwargs)
     1018         try:
  -&gt; 1019             return self._cython_agg_general('mean')
     1020         except GroupByError:
     1021             raise
  
  /root/anaconda3/lib/python3.6/site-packages/pandas/core/groupby.py in     _cython_agg_general(self, how, numeric_only)
      806 
      807         if len(output) == 0:
  --&gt; 808             raise DataError('No numeric types to aggregate')
      809 
      810         return self._wrap_aggregated_output(output, names)
  
  DataError: No numeric types to aggregate
  </code></pre>
  
  <p>ohh..what did I wrong?Why can't I mean the second pandas.DataFrame? It's completely same as the successful example!</p>