Kurtosis on Pandas Working with Dataframe Data

When I apply the kurtosis function to pandas datafame, I always get the following error:

AttributeError: cannot access attribute "kurt" DataFrameGroupBy objects, try using the 'apply' method

The following code example works with all other statistical functions (mean (), skew (), ...), but not with an excess.

df = pd.DataFrame([[0,1,1,0,0,1],[0,1,2,4,5]]).T df.columns = ['a','b'] df.groupby('a').kurt() 

Any idea how I can apply an excess after a group? Thanks!

+5
source share
1 answer

According to the API reference, kurt not a method of the DataFrameGroupBy class, but mean and skew are located.

This should work:

 df.groupby('a').apply(pd.DataFrame.kurt) 
+6
source

All Articles