deephaven_enterprise.pivot.client.formatter¶
Text formatting utilities for PivotSnapshot
objects.
These formatting methods are intended to ease debugging of your application by providing a mechanism to dump textual representations of a Pivot snapshot. The grid method can be used as an example for extracting relevant details from the snapshot into a usable form for your application.
- build_pivot_grid(snap)[source]¶
Builds a grid (two-dimensional array) representation of a pivot table snapshot.
The grid is not intended for computation, but instead for simple debugging and an example of how to extract useful data from a
PivotSnapshot
.The grid includes a header row with the colum names; a row for the depth of each column, a row for the expanded state of each column, and a row totals of each column (and the grand totals), and a row for each column by-column.
The grid starts with a label column for the column depth, expanded state, and each column by-column’s name. The next columns are the row depth, row expanded state, row-by-column values, row totals, and then the remaining columns are the field of values for each row/column by-column key combination.
- Parameters:
snap (PivotSnapshot) – The pivot table snapshot to convert into a grid.
- Returns:
A 2D grid where each cell contains a string representation of the data.
- Return type:
- format_snapshot(snap)[source]¶
Formats a pivot table snapshot into a human-readable string representation, using
build_pivot_grid()
to build the grid.- Parameters:
snap (PivotSnapshot) – The pivot table snapshot to format.
- Returns:
A formatted string representation of the pivot table with aligned columns.
- Return type: