没有要聚合的数字类型

时间:2019-06-14 21:37:23

标签: jupyter-notebook

代码显示错误,不知道如何解决:

  

“没有要聚合的数字类型”

df_grp = df_test.groupby(['drive-wheels', 'body-style'], as_index=False).mean()
df.grp
DataError                                 Traceback (most recent call last)
<ipython-input-44-e5bd29b41b71> in <module>
----> 1 df_grp = df_test.groupby(['drive-wheels', 'body-style'], as_index=False).mean ()
      2 df.grp

C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\groupby\groupby.py in mean(self, *args, **kwargs)
   1130         nv.validate_groupby_func('mean', args, kwargs, ['numeric_only'])
   1131         try:
-> 1132             return self._cython_agg_general('mean', **kwargs)
   1133         except GroupByError:
   1134             raise

C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\groupby\generic.py in _cython_agg_general(self, how, alt, numeric_only, min_count)
     68                             min_count=-1):
     69         new_items, new_blocks = self._cython_agg_blocks(
---> 70             how, alt=alt, numeric_only=numeric_only, min_count=min_count)
     71         return self._wrap_agged_blocks(new_items, new_blocks)
     72 

C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\groupby\generic.py in _cython_agg_blocks(self, how, alt, numeric_only, min_count)
    141 
    142         if len(new_blocks) == 0:
--> 143             raise DataError('No numeric types to aggregate')
    144 
    145         # reset the locs in the blocks to correspond to our

DataError: No numeric types to aggregate

0 个答案:

没有答案