Skip to content

Auto-group

The lowest-friction path: hand the grid a flat frame and nothing else. With auto-group on, schema inference picks the row hierarchy — the non-numeric columns, ordered by ascending cardinality so the coarsest dimension nests outermost — and turns every numeric column into a summed measure. It is a starting point, not a straitjacket: any explicit rows / measures you pass always win.

from dash_tensor_grid import TensorGrid, build_grid
# No rows / measures — the engine infers both from the data.
payload = build_grid(sales, {
"auto_group": True,
"formats": {"revenue": "currency:USD", "cost": "currency:USD"},
})
TensorGrid(id="grid", row_data=payload["row_data"], column_defs=payload["column_defs"])
  • Dimensions by ascending cardinality. Columns with fewer distinct values group first, so a region → country → city-shaped frame nests in that order without you naming it.
  • Numeric columns become sum measures by default. Pass an explicit measures map to change an aggregation or drop a numeric column from the roll-up — your map takes precedence over inference.
  • Cap the depth. Dash accepts max_levels (engine.infer_schema) to limit how many dimension levels are derived; omit it for the engine default.
  • Explicit always wins. Provide rows and auto-group only fills in the measures, or vice versa — inference runs only for the axis you left empty.
  • Once you know the shape, prefer spelling out aggregation rows/measures for a stable, reviewable config.