Signup/Sign In
PUBLISHED ON: MARCH 19, 2021

Pandas DataFrame kurt() Method

In this tutorial, we will learn the Python pandas DataFrame.kurt() method. This method returns unbiased kurtosis over the requested axis.

Kurtosis obtained using Fisher’s definition of kurtosis (kurtosis of normal == 0.0). Normalized by N-1. The below shows the syntax of the DataFrame.kurt() method.

Syntax

DataFrame.kurt(axis=None, skipna=None, level=None, numeric_only=None, **kwargs)

Parameters

axis: {index (0), columns (1)}. Axis for the method to be applied on.

skipna: bool, default True. Exclude NA/null values when computing the result.

level: int or level name, default None. If the axis is a MultiIndex (hierarchical), count along with a particular level, collapsing into a Series.

numeric_only: bool, default None. Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.

**kwargs: Additional keyword arguments to be passed to the method.

Example: The DataFrame.kurt() Method

In this example, we are using the DataFrame.kurt() method along the axis=0 to get unbiased kurtosis of the dataframe.

#importing pandas as pd
import pandas as pd
#creating DataFrame
df=pd.DataFrame({"A":[55,60,74,50],"B":[30,55,40,47],"C":[12,55,44,66]})
print("-----------The DataFrame is-------")
print(df)
print("-------------------------------")
print(df.kurt(axis=0))

Once we run the program we will get the following output.


-----------The DataFrame is-------
A B C
0 55 30 12
1 60 55 55
2 74 40 44
3 50 47 66
-------------------------------
A 1.307557
B -0.466318
C 1.414727
dtype: float64

Example: The DataFrame using the DataFrame.kurt() Method

The following example shows the DataFrame.kurt() method by excluding null values. It returns non-null values.

#importing pandas as pd
import pandas as pd
#creating DataFrame
df=pd.DataFrame({"A":[55,60,None,60,50],"B":[42,30,None,40,47],"C":[None,75,55,44,66]})
print(df.kurt(axis=0,skipna=True))

Once we run the program we will get the following output.


A -1.289256
B 1.704496
C -1.441136
dtype: float64

Example: The DataFrame using the DataFrame.kurt() Method

The following code shows the example of the DataFrame.kurt() method which includes only numeric values.

#importing pandas as pd
import pandas as pd
#creating DataFrame
df=pd.DataFrame({"A":[55,60,None,60,50],"B":[42,30,None,40,47],"C":[None,75,55,44,66]})
print(df.kurt(axis=0,numeric_only=True))

Once we run the program we will get the following output.


A -1.289256
B 1.704496
C -1.441136
dtype: float64

Conclusion

In this tutorial, we learned the Python pandas DataFrame.kurt() method. We learned the syntax and applying this method on the DataFrame to understand the DataFrame.kurt() method.



About the author:
I like writing about Python, and frameworks like Pandas, Numpy, Scikit, etc. I am still learning Python. I like sharing what I learn with others through my content.