FutureWarning
1、python机器学习实践指南,原书代码:
df.groupby('class')['petal width']\.agg({'delta': lambda x :x.max() - x.min(), 'max': np.max,'min':np.min})

2、运行后报错:FutureWarning: using a dict on a Series for aggregationis deprecated and will be removed in a future version 'max': np.max,'min':np.min})

3、修改如下:
def delta(group): return max(group) - min(group)df.groupby('class')['petal width'].agg([delta])

4、运行结果:如下图

5、详情请参见:
http://pandas.pydata.org/pandas-docs/stable/.打不开请越狱
6、有用的话请给我投票吧,谢谢!!!
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:111
阅读量:177
阅读量:93
阅读量:59
阅读量:119