Embedded Python API
Use typed arguments with a DuckDB connection configured by your application.
View the Python source
TimeSeriesChart
TimeSeriesDataset
Trusted main-schema relation, timestamp, unique tie-breaker and numeric series columns.
relation: strtime_column: strorder_column: strmeasures: Mapping[str, str]
LineChartSpec
dataset_id: strmeasure_id: strstart: datetimeend: datetimewidth: inttitle: str
BucketSize
MINUTE = 'minute'HOUR = 'hour'DAY = 'day'MONTH = 'month'
BucketObservation
bucket: datetimeseries_id: strmean: float | Noneobservations: int
ChartBuilder
Resolve caller chart specifications against the host's dataset registry.
__init__(self, connection: DuckDBPyConnection, datasets: Mapping[str, TimeSeriesDataset])line(self, spec: LineChartSpec) → str | NoneProject a half-open time window and reduce it before rendering.
bucketed_series(self, dataset_id: str, series: tuple[str, ...], start: datetime, end: datetime, *, size: BucketSize) → list[BucketObservation]Aggregate requested wide columns in one scan, then emit long rows.
StateInterval
start: datetimeend: datetimestate: str
StateTimeline
Compress consecutive equal events to half-open, bounded validity intervals.
__init__(self, connection: DuckDBPyConnection)reduce(self, times: list[datetime], states: list[str | None], *, start: datetime, end: datetime, max_gap: timedelta) → list[StateInterval]
CalendarRange
CalendarDay
day: datestate: strvalue: float | Noneobservations: int
CalendarData
Fill a date grid with separate observed, missing and out-of-coverage states.
__init__(self, connection: DuckDBPyConnection)daily(self, times: list[datetime], values: list[float | None], *, displayed: CalendarRange, covered: CalendarRange, timezone_name: str) → list[CalendarDay]
MarketSession
session_id: strstart: datetimeend: datetime
QuoteTrade
time: datetimesequence: intprice: floatvolume: float
MarketBar
session_id: stropen: float | Nonehigh: float | Nonelow: float | Noneclose: float | Nonevolume: float | Nonetrades: int
OHLC
Aggregate trades by explicit market sessions and tie-break on exchange sequence.
__init__(self, connection: DuckDBPyConnection)bars(self, sessions: list[MarketSession], trades: list[QuoteTrade]) → list[MarketBar]
SeriesPoint
time: datetimekey: intvalue: float | None
SeriesDifference
time: datetimekey: intold: float | Nonenew: float | Nonedelta: float | Noneratio: float | Nonestate: str
TimeSeriesDiff
Align two chart revisions by timestamp and stable row identity.
SankeyLink
stage: intsource: strdestination: str | Noneweight: floatcollapsed: bool = False
SankeySummary
links: tuple[SankeyLink, ...]stage_totals: tuple[tuple[int, float], ...]invalid_rows: int
SankeyFlow
Summarize nonnegative movement between consecutive named stages.
GridWindow
x_start: intx_end: inty_start: inty_end: int
HeatmapCell
x: inty: intstate: strvalue: float | None
SparseHeatmap
Read a registered relation with unique (xbin, ybin) cell IDs.
__init__(self, connection: DuckDBPyConnection, relation: str, *, columns: int, rows: int)sparse(self, window: GridWindow) → list[HeatmapCell]dense(self, window: GridWindow) → list[HeatmapCell]
VoxelSpec
lower: tuple[float, float, float]upper: tuple[float, float, float]bins: tuple[int, int, int]
Voxel
cell: tuple[int, int, int]count: intcenter: tuple[float, float, float]mean_color: float | None
VoxelPoint
point_id: intposition: tuple[float, float, float]color: float | None
VoxelGrid
Aggregate three-dimensional points in a registered DuckDB table.
__init__(self, connection: DuckDBPyConnection, relation: str)summarize(self, spec: VoxelSpec) → list[Voxel]points(self, spec: VoxelSpec, cell: tuple[int, int, int], *, limit: int, after_id: int | None=None) → list[VoxelPoint]chart(self, spec: VoxelSpec, *, title: str) → str
HierarchyNode
key: strparent: str | Nonelabel: strweight: float | None = None
TreeMapArea
key: strparent: str | Nonelabel: strdepth: inttotal: float
TreeMap
Build a leaf-weight hierarchy and render only the requested subtree depth.
__init__(self, connection: DuckDBPyConnection)summarize(self, nodes: list[HierarchyNode], *, root: str, max_depth: int) → list[TreeMapArea]chart(self, nodes: list[HierarchyNode], *, root: str, max_depth: int, title: str) → str
HistogramResult
counts: tuple[int, ...]missing: intoutside: int
LogHistogramResult
edges: tuple[float, ...]counts: tuple[int, ...]missing: intoutside: intnonpositive: int
ScatterExtent
xmin: floatymin: floatxmax: floatymax: float
DensityCell
column: introw: intcount: int
ScatterSelection
visible_count: intcells: tuple[DensityCell, ...]points: tuple[tuple[float, float], ...]
ScatterDensity
Use a visible point budget to choose exact points or a compact count grid.
__init__(self, connection: DuckDBPyConnection)fetch(self, x: list[float | None], y: list[float | None], extent: ScatterExtent, *, columns: int, rows: int, point_limit: int) → ScatterSelection
Histogram
Compute numeric bin counts on a host-provisioned DuckDB connection.
__init__(self, connection: DuckDBPyConnection)count(self, values: list[float | None], edges: list[float]) → HistogramResultUse left-closed bins, including the right edge of the final bin.
count_log(self, values: list[float | None], *, lower: float, upper: float, bins: int) → LogHistogramResultCount exponentially spaced bins with returned edges in original units.
BoxSummary
group_id: intcount: intq1: float | Nonemedian: float | Noneq3: float | Nonelower_whisker: float | Noneupper_whisker: float | Noneoutlier_count: intoutlier_examples: tuple[float, ...]
CategoryTotal
kind: strcategory_id: int | Nonelabel: strtotal: float | None
DegreeCount
direction: strdegree: intvertices: int
ErrorBarMethod
STANDARD_ERROR = 1.0NORMAL_95 = 1.959963984540054
ErrorBar
group_id: intcount: intmean: float | Nonevariance: float | Nonelower: float | Noneupper: float | Nonemethod: ErrorBarMethodreason: str | None
WeightedMean
group_id: intweighted_sum: floatweight: floatmean(self) → float | None
GroupedStatistics
Return compact chart data computed on the host's DuckDB connection.
__init__(self, connection: DuckDBPyConnection)boxplot(self, groups: list[int], values: list[float | None], *, outlier_limit: int=0) → list[BoxSummary]Use continuous quartiles, observed Tukey whiskers, and bounded outlier samples.
boxplot_html(self, groups: list[int], values: list[float | None], *, title: str, outlier_limit: int=0) → strRender the precomputed boxes as a Plotly trace.
top_categories(self, categories: list[int | None], values: list[float | None], labels: dict[int, str], *, limit: int) → list[CategoryTotal]Aggregate by stable ID and preserve distinct missing and remainder totals.
degree_distribution(self, vertices: list[int], edges: list[tuple[int, int, int]]) → list[DegreeCount]Count weighted directed degrees with one incoming and outgoing contribution per loop.
weighted_means(self, groups: list[int], values: list[float | None], weights: list[float]) → list[WeightedMean]Keep the numerator and valid weight for each group for later rollups.
combine_weighted_means(self, groups: list[WeightedMean], parents: dict[int, int]) → list[WeightedMean]Roll up summaries using only their two stored aggregate components.
error_bars(self, groups: list[int], values: list[float | None], *, method: ErrorBarMethod) → list[ErrorBar]Calculate sample variance and an interval around each group mean.