Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: Cannot access callable attribute 'groupby' of 'DataFrameGroupBy' objects

I have a dataframe that has 3 columns -

enter image description here

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()

but this throws an error -

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?

like image 833
harry04 Avatar asked Nov 21 '18 05:11

harry04


1 Answers

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

like image 159
harry04 Avatar answered Oct 10 '22 00:10

harry04