Spaces:
Running
Running
metadata
id: duckdb-summarize
title: Histogram
slug: duckdb-histogram-query
description: >-
Create a histogram for a specific column to visualize the distribution of
values.
code: |
from histogram(
table_name,
column_name,
bin_count := 10
)
DuckDB Histogram
This snippet demonstrates how to use the Histogram
function in DuckDB to calculate aggregate statistics for a dataset. The histogram
function in DuckDB is used to compute histograms over columns of a dataset. It works for columns of any type and allows for various binning strategies and a custom number of bins.
from histogram(
table_name,
column_name,
bin_count := 10
)
Parameters
table_name
: The name of the table or a subquery result.column_name
: The name of the column for which to create the histogram, you can use different expressions to summarize the data such as length of a string.bin_count
: The number of bins to use in the histogram.
Histogram of the length of the input persona from the PersonaHub
dataset
from histogram(
instruction,
len("input persona"),
bin_count := 5
)