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.
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).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
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
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
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).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 kurt() examples interactively directly in your browser:
Reference: Pandas kurt() documentation.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.