describe() returns a single named-tuple-like result containing several statistics at once: nobs, number of observations, minmax, a tuple of the min and max, mean, variance, skewness, a measure of the distribution's asymmetry, and kurtosis, a measure of how heavy-tailed the distribution is compared to a normal distribution. Unlike NumPy's individual functions like np.mean() or np.var(), which each compute one statistic at a time, describe() bundles the most commonly needed ones together in one efficient pass over the data, similar in spirit to pandas' df.describe(), but returning skewness and kurtosis by default, which pandas' version doesn't.
1Understanding stats.describe()
describe() returns a single named-tuple-like result containing several statistics at once: nobs, number of observations, minmax, a tuple of the min and max, mean, variance, skewness, a measure of the distribution's asymmetry, and kurtosis, a measure of how heavy-tailed the distribution is compared to a normal distribution. Unlike NumPy's individual functions like np.mean() or np.var(), which each compute one statistic at a time, describe() bundles the most commonly needed ones together in one efficient pass over the data, similar in spirit to pandas' df.describe(), but returning skewness and kurtosis by default, which pandas' version doesn't.
scipy.stats.describe()'s variance uses ddof=1, sample variance, dividing by N-1, by default, matching pandas' default, but differing from NumPy's np.var(), which defaults to ddof=0, population variance — be aware of this difference if you're cross-checking values between the two libraries.
from scipy import stats
import numpy as np
data = np.array([2, 4, 4, 4, 5, 5, 7, 9])
result = stats.describe(data)
print(result.mean, result.variance)2Practical Example
Here is a real-world application of stats.describe() showing how it is used in production SciPy code.
from scipy import stats
import numpy as np
data = np.array([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])
result = stats.describe(data)
print(result.nobs, result.minmax)3Best Practices
Follow these guidelines when working with stats.describe():
1. Use describe() for a quick, one-call summary bundling several statistics together, instead of computing each one separately with individual functions
2. Interpret skewness and kurtosis relative to a normal distribution's reference values, skewness 0, excess kurtosis 0, rather than in isolation, since they're most meaningful as a comparison to normality
3. Be aware of the ddof default difference between scipy.stats' sample variance and NumPy's population variance default, when cross-checking values between the two
Tip: scipy.stats.describe()'s variance uses ddof=1, sample variance, dividing by N-1, by default, matching pandas' default, but differing from NumPy's np.var(), which defaults to ddof=0, population variance — be aware of this difference if you're cross-checking values between the two libraries.
from scipy import stats
import numpy as np
data = np.array([2, 4, 4, 4, 5, 5, 7, 9])
result = stats.describe(data)
print(result.mean, result.variance)