DAAF-Contribution-Community/daaf / .claude/skills/great-tables
great-tables
VerifiedPython table formatting with great-tables: publication-quality display tables from Polars/pandas DataFrames. GT() grammar-of-tables object, fmt_*() number formatting, tab_*() structure (header, spanners, stub, source notes), tab_style() and data_color() styling, cols_*() column operations, and HTML/LaTeX export via as_raw_html()/write_raw_html()/as_latex(). Use when execution language is Python and the task involves formatted data tables, summary tables, or descriptive-stat tables for reports. R equivalent: gt (use when execution language is R). For regression/model tables in Python, use the estimator's own output (pyfixest etable(), statsmodels summary()) — great-tables has no modelsummary equivalent. For figures/charts use plotnine or plotly, not this skill.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.8 KB |
| references/export.md | markdown | 4.0 KB |
| references/formatting-structure.md | markdown | 7.3 KB |
| references/quickstart.md | markdown | 3.7 KB |
references/quickstart.md
View on GitHub# Great Tables Quickstart
All examples below were executed against great-tables 0.21.0 in the DAAF container.
## Imports
```python
import polars as pl
import great_tables as gt
from great_tables import loc, style, md, html, px, pct, vals
```
- `gt.GT` — the table object (constructor).
- `loc` — location selectors (`loc.body`, `loc.column_labels`, `loc.stub`, etc.) for targeting styles.
- `style` — style constructors (`style.fill`, `style.text`, `style.borders`).
- `md`, `html` — mark a string as Markdown / raw HTML (for titles, source notes, cells via `fmt_markdown`).
- `px`, `pct` — CSS length helpers (e.g. `px(150)`).
- `vals` — format scalar value lists without building a table.
## Building a table from a Polars DataFrame
great-tables accepts a Polars DataFrame directly (pandas also works; Polars is the
DAAF default). Every method returns a new `GT`, so operations method-chain with `.`.
```python
df = pl.DataFrame({
"region": ["A", "B", "C"],
"revenue": [12345.6, 23456.7, 34567.8],
"share": [0.123, 0.234, 0.345],
})
tbl = (
gt.GT(df)
.tab_header(title="Revenue by Region", subtitle="FY2025")
.fmt_currency(columns="revenue", currency="USD", decimals=2)
.fmt_percent(columns="share", decimals=1)
.cols_label(revenue="Revenue", share="Share")
)
html_str = tbl.as_raw_html() # 'Revenue by Region', '$12,345.60', '12.3%' all present
```
> **Constructor caveat:** use `gt.GT(df)`. Do **not** use `gt.GT.from_data(df)` — it
> is broken in 0.21.0 (raises `TypeError` on an internal `_tbl_data` argument).
## Row-group stub
Pass `rowname_col` and `groupname_col` to the constructor to create a stub (the
labeled left-hand column) with row groups. This mirrors R gt's row-group behavior.
```python
df = pl.DataFrame({
"group": ["North", "North", "South", "South"],
"region": ["A", "B", "C", "D"],
"revenue": [12345.6, 23456.7, 34567.8, 45678.9],
})
tbl = (
gt.GT(df, rowname_col="region", groupname_col="group")
.tab_stubhead(label="Region")
.fmt_currency(columns="revenue", currency="USD")
)
```
## Header, source notes, footnotes
```python
tbl = (
gt.GT(df)
.tab_header(title="Table Title", subtitle="Optional subtitle")
.tab_source_note(source_note=md("Source: *synthetic test data*, 2025."))
)
```
- `tab_header(title=..., subtitle=...)` — title/subtitle block above the table.
- `tab_source_note(source_note=...)` — a note below the table. Wrap in `md(...)` for
Markdown or `html(...)` for raw HTML; a plain string renders as literal text.
- Footnotes attach to locations via `tab_style`/footnote APIs — see
`formatting-structure.md`.
## Basic number formatting
The `fmt_*` family targets columns by name (string) or list of names. Applied
left-to-right in the chain; later formatters on the same column win.
```python
tbl = (
gt.GT(df)
.fmt_number(columns=["revenue"], decimals=2) # 12,345.60
.fmt_percent(columns="share", decimals=1) # 12.3%
.fmt_currency(columns="revenue", currency="USD") # $12,345.60
.fmt_integer(columns="count") # 1,234
)
```
Common `fmt_*` methods (full list in `formatting-structure.md`):
`fmt_number`, `fmt_integer`, `fmt_percent`, `fmt_currency`, `fmt_date`,
`fmt_datetime`, `fmt_time`, `fmt_scientific`, `fmt_engineering`, `fmt_bytes`,
`fmt_roman`, `fmt_markdown`, `fmt_units`, `fmt_image`, `fmt_flag`, `fmt_icon`.
## Renaming and aligning columns
```python
tbl = (
gt.GT(df)
.cols_label(revenue="Revenue", share="Market Share")
.cols_align(align="right", columns=["revenue", "share"])
)
```
## Next steps
- Detailed formatting, styling, spanners, summary rows, column ops →
`./formatting-structure.md`
- Exporting to HTML/LaTeX and the image-export limitation → `./export.md`
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |