AttributeError:无法访问"DataFrameGroupBy"对象的可调用属性"groupby" [英] AttributeError: Cannot access callable attribute 'groupby' of 'DataFrameGroupBy' objects

查看:69
本文介绍了AttributeError:无法访问"DataFrameGroupBy"对象的可调用属性"groupby"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3列的数据框-

I have a dataframe that has 3 columns -

我想通过执行类似这样的操作,根据筷子长度"对列进行分组-

I want to group the columns on the basis of Chopstick Length by doing something like this -

meansByCL = df_chopstick.groupby('Chopstick.Length')['Food.Pinching.Efficiency'].mean().reset_index()

但这会引发错误-

AttributeError: Cannot access callable attribute 'groupby' of 'DataFrameGroupBy' objects, try using the 'apply' method

我不确定这个错误是什么意思.谁能告诉我我做错了什么或如何以不同的方式编写此代码?

I'm not sure what this error means. Can anyone tell me what I'm doing wrong or how I can write this code differently?

推荐答案

当您尝试对以前已经分组的数据框进行 groupby()时,就会发生这种情况!

This happens when you are trying to groupby() a dataframe which has been already grouped before!

这篇关于AttributeError:无法访问"DataFrameGroupBy"对象的可调用属性"groupby"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆