Pandas: Calculate Kurtosis with kurt()

Compute unbiased excess kurtosis for values across Series or DataFrames using the Pandas kurt() (or kurtosis()) method. Evaluate tail heaviness, measure potential outlier risks in datasets, and configure calculation axes.

Introduction to kurt() 🔝

The kurt() method (an alias for kurtosis()) measures the tail heaviness of a distribution relative to a normal distribution. By default, Pandas reports excess kurtosis where a normal distribution yields 0.0, positive values indicate heavy tails (leptokurtic with high outlier probability), and negative values indicate light tails (platykurtic).

Create numerical sample DataFrame 🔝

We start with a multi-column numerical DataFrame containing measurement variables.
import pandas as pd

df = pd.DataFrame({
    "A": [1, 2, 3, 4, 5, 6, 7, 8, 9],
    "B": [2, 2, 2, 5, 5, 5, 8, 8, 8]
})
print(df)
assert df.shape == (9, 2)

Expected output

   A  B
0  1  2
1  2  2
2  3  2
3  4  5
4  5  5
5  6  5
6  7  8
7  8  8
8  9  8

Basic kurtosis calculation 🔝

Call kurt() on the DataFrame to compute excess kurtosis across numerical columns.
res = df.kurt()
print(res)
assert res["A"] == -1.2

Expected output

A   -1.20
B   -1.75
dtype: float64

Kurtosis on a single Series 🔝

Apply kurt() or its alias kurtosis() directly to a single column or standalone Series.
k_val = df["A"].kurtosis()
print(f"Excess Kurtosis: {k_val}")
assert k_val == -1.2

Expected output

Excess Kurtosis: -1.2

Exercise: compute return kurtosis 🔝

Given a Series vals = pd.Series([10, 10, 10, 10, 50], name="VAL"), compute its excess kurtosis using kurt() and verify that it evaluates to 5.0 (indicating a heavy tail outlier).

Exercise solution 🔝

Solution creating the Series and applying kurt().
vals = pd.Series([10, 10, 10, 10, 50], name="VAL")
answer = vals.kurt()
print(answer)
assert answer == 5.0

Expected output

5.0

Practice in Google Colab 🔝

Interactive Colab Notebook

Practice kurt() examples interactively directly in your browser:

Open In Colab View on GitHub

Reference: Pandas kurt() documentation.




Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer