You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,8 @@ Returns a `PivotTableResult` dict containing the current `config` state.
57
57
|`values`|`list[str] \| None`|`None`| Column names to aggregate as measures. |
58
58
|`synthetic_measures`|`list[dict] \| None`|`None`| Derived measures computed from source-field sums (for example, ratio of sums). See [Synthetic Measures](#synthetic-measures-v1). |
59
59
|`aggregation`|`str \| dict[str, str]`|`"sum"`| Aggregation setting for raw value fields. A single string applies to every raw measure; a dict enables per-measure aggregation. See [Aggregation Functions](#aggregation-functions). |
60
+
|`auto_date_hierarchy`|`bool`|`True`| Auto-group typed date/datetime fields placed on rows or columns. Default grain is adaptive based on the source data's date range (year for >2 years, quarter for >1 year, month for >2 months, day for shorter ranges). |
61
+
|`date_grains`|`dict[str, str \| None] \| None`|`None`| Per-field temporal overrides. Use `"year"`, `"quarter"`, `"month"`, `"week"`, or `"day"`. Use `None` for an explicit `Original` opt-out. |
60
62
|`interactive`|`bool`|`True`| Enable end-user config controls. When `False`, the toolbar is hidden and header-menu sort/filter/show-values-as actions are disabled. |
61
63
62
64
#### Totals and Subtotals
@@ -240,6 +242,10 @@ Display measures as percentages instead of raw numbers.
240
242
| % of Grand Total |`"pct_of_total"`| Cell / Grand Total |
241
243
| % of Row Total |`"pct_of_row"`| Cell / Row Total |
242
244
| % of Column Total |`"pct_of_col"`| Cell / Column Total |
245
+
| Diff vs Previous Period |`"diff_from_prev"`| Current bucket minus previous bucket on the active temporal hierarchy |
246
+
| % Diff vs Previous Period |`"pct_diff_from_prev"`| Percent change vs previous bucket |
247
+
| Diff vs Previous Year |`"diff_from_prev_year"`| Current bucket minus same bucket in the prior year |
248
+
| % Diff vs Previous Year |`"pct_diff_from_prev_year"`| Percent change vs same bucket in the prior year |
243
249
244
250
```python
245
251
st_pivot_table(
@@ -254,6 +260,72 @@ st_pivot_table(
254
260
255
261
Users can also change this interactively via the value header menu (**⋮** icon on a value label header).
256
262
Synthetic measures are always rendered as raw derived values (`show_values_as` does not apply to them).
263
+
Period-comparison modes appear only when there is an active grouped temporal axis, whether that grouping came from auto hierarchy or an explicit `date_grains` override.
264
+
265
+
### Date Hierarchy and Time Comparisons
266
+
267
+
Typed `date` and `datetime` fields are treated as hierarchy-capable dimensions when they are placed on `rows` or `columns`.
268
+
269
+
-**Adaptive default grain**: with `auto_date_hierarchy=True`, temporal axis fields auto-group based on the date range of the source data (after `source_filters`):
0 commit comments