Reference · Statistics

stats.describe

signature
stats.describe(list | null) -> map

What it does

A summary of a list of numbers in one map, as a data frame's describe: { count, sum, mean, std, min, q1, median, q3, max }. std is the sample standard deviation (stats.stdev) and the quartiles follow numpy's linear rule (stats.percentile at 25, 50 and 75). It is not in Python's statistics module.

Examples

print(stats.describe([1, 2, 3, 4]))let d = stats.describe([72, 85, 90, 66, 85, 78])print(d.count, d.mean, d.q3 - d.q1)
output
{ count: 4, sum: 10, mean: 2.5, std: 1.2909944487358056, min: 1, q1: 1.75, median: 2.5, q3: 3.25, max: 4 }6 79.33333333333333 11.5

Edge cases

print(stats.describe([]))print(stats.describe(null).count)print(stats.describe([7]))print(stats.describe([2.5, 1.5]))
output
{ count: 0, sum: 0, mean: null, std: null, min: null, q1: null, median: null, q3: null, max: null }0{ count: 1, sum: 7, mean: 7.0, std: null, min: 7, q1: 7.0, median: 7.0, q3: 7.0, max: 7 }{ count: 2, sum: 4.0, mean: 2.0, std: 0.7071067811865476, min: 1.5, q1: 1.75, median: 2.0, q3: 2.25, max: 2.5 }

Errors

An item that is not a number is a runtime error, not an error value. So is an argument that is not a list or null.

this one fails
print(stats.describe([1, "a"]))
output
line 1: `stats.describe` expects a list of numbers, but item 1 is str
this one fails
print(stats.describe(42))
output
line 1: `stats.describe` expects a list as argument 1, got int

Chaining

print([3, 1, 2] | stats.describe | get("median"))let summary = [{ total: 12.5 }, { total: 30 }, { total: 7.5 }] | vec.column("total") | stats.describeprint(summary.min, summary.max, summary.mean | round(2))
output
2.07.5 30.0 16.67

See also

stats.mean, stats.stdev, stats.percentile, stats.quantiles, min, max, sum

Thread
9Useful? Like it, or add to its thread below.

Thread 0 posts

On stats.describe(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo