DESCRIBE
Overview
The DESCRIBE
function computes descriptive statistics of a dataset, including the number of elements, minimum and maximum values, mean, variance, skewness, and kurtosis. It is a wrapper for the scipy.stats.describe
function, which provides a convenient summary of the central tendency, dispersion, and shape of a dataset’s distribution. This function is useful for quickly summarizing the main characteristics of a dataset in Excel. For more details, see the scipy.stats.describe documentation .
This function exposes the most commonly used parameters: the data array and an option to specify if the data is already flattened. The axis
and nan_policy
parameters are not exposed for simplicity. This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=DESCRIBE(data, [ddof], [bias])
data
(2D list, required): Table of numeric values (float). Must have at least two rows and one column.ddof
(int, optional, default=0): Delta degrees of freedom for variance calculation.bias
(bool, optional, default=False): If True, calculations are corrected for statistical bias.
The function returns a 2D list with a single row containing the following values: [nobs, min, max, mean, variance, skewness, kurtosis], or an error message (list of strings) if the input is invalid.
Examples
Example 1: Basic Statistics
Inputs:
data | ddof | bias | ||
---|---|---|---|---|
1 | 2 | 3 | 0 | FALSE |
4 | 5 | 6 |
Excel formula:
=DESCRIBE({1,2,3;4,5,6}, 0, FALSE)
Expected output:
nobs | min | max | mean | variance | skewness | kurtosis |
---|---|---|---|---|---|---|
6 | 1 | 6 | 3.5 | 2.9167 | 0 | -1.2 |
Example 2: With ddof=1
Inputs:
data | ddof | bias | ||
---|---|---|---|---|
1 | 2 | 3 | 1 | FALSE |
4 | 5 | 6 |
Excel formula:
=DESCRIBE({1,2,3;4,5,6}, 1, FALSE)
Expected output:
nobs | min | max | mean | variance | skewness | kurtosis |
---|---|---|---|---|---|---|
6 | 1 | 6 | 3.5 | 3.5 | 0 | -1.2 |
Example 3: With bias correction
Inputs:
data | ddof | bias | ||
---|---|---|---|---|
1 | 2 | 3 | 0 | TRUE |
4 | 5 | 6 |
Excel formula:
=DESCRIBE({1,2,3;4,5,6}, 0, TRUE)
Expected output:
nobs | min | max | mean | variance | skewness | kurtosis |
---|---|---|---|---|---|---|
6 | 1 | 6 | 3.5 | 2.9167 | 0 | -1.2686 |
Example 4: Different Data
Inputs:
data | ddof | bias | ||
---|---|---|---|---|
10 | 20 | 30 | 0 | FALSE |
40 | 50 | 60 |
Excel formula:
=DESCRIBE({10,20,30;40,50,60}, 0, FALSE)
Expected output:
nobs | min | max | mean | variance | skewness | kurtosis |
---|---|---|---|---|---|---|
6 | 10 | 60 | 35 | 291.6667 | 0 | -1.2 |
This means the function returns a summary row with the main descriptive statistics for the input data.
Python Code
from scipy.stats import describe as scipy_describe
def describe(data, ddof=0, bias=False):
"""
Compute descriptive statistics of a dataset: nobs, min, max, mean, variance, skewness, kurtosis.
Args:
data: 2D list of numbers (float), at least two rows and one column.
ddof: Delta degrees of freedom for variance calculation (int, default: 0).
bias: If True, calculations are corrected for statistical bias (bool, default: False).
Returns:
2D list with a single row: [nobs, min, max, mean, variance, skewness, kurtosis], or a list of strings if input is invalid.
This example function is provided as-is without any representation of accuracy.
"""
# Validate data
if not isinstance(data, list) or len(data) < 2 or not isinstance(data[0], list):
return [["Invalid input: data must be a 2D list with at least two rows."]]
try:
flat = [float(x) for row in data for x in row]
except Exception:
return [["Invalid input: data must contain only numbers."]]
if len(flat) < 2:
return [["Invalid input: data must contain at least two values."]]
try:
res = scipy_describe(flat, ddof=ddof, bias=bias)
except Exception as e:
return [[f"scipy.stats.describe error: {e}"]]
# Prepare output row
out = [
int(res.nobs),
float(res.minmax[0]),
float(res.minmax[1]),
float(res.mean),
float(res.variance),
float(res.skewness),
float(res.kurtosis),
]
return [out]