DataFrame groupby+agg出现SpecificationError: nested renamer is not supported的错误
生活随笔
收集整理的這篇文章主要介紹了
DataFrame groupby+agg出现SpecificationError: nested renamer is not supported的错误
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這個應該是pandas的版本問題 ,我的是v1.0.5,也會出現這個問題,如下面的代碼所示:
>>> import pandas as pd >>> data=pd.DataFrame({'name':['x','y','x','y','z'],'sex':['f','m','f','f','m'],'age':[25,26,45,67,30]}) >>> dataname sex age 0 x f 25 1 y m 26 2 x f 45 3 y f 67 4 z m 30 >>> data.groupby('name')['age'].agg({'sums':'sum'}) Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/groupby/generic.py", line 253, in aggregateret = self._aggregate_multiple_funcs(func)File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/groupby/generic.py", line 294, in _aggregate_multiple_funcsraise SpecificationError("nested renamer is not supported") pandas.core.base.SpecificationError: nested renamer is not supported將代碼改成下面的方式就可以了
- 根據單列聚合后進行單個計算
- 根據單列聚合后進行多個計算?
- 根據多列聚合后進行多個計算
?
總結
以上是生活随笔為你收集整理的DataFrame groupby+agg出现SpecificationError: nested renamer is not supported的错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 平衡记分卡(转载)
- 下一篇: 基于php的仓库管理系统