Commercial enterprise offerings
2025-06-05

Level Up Your Python Tables: Structure, Style, and Clarity with Great Tables

Isabella Velásquez's head shot
Written by Isabella Velásquez
Great Tables logo with arrows pointing up above the logo
Share

Get our email updates

Interested in learning more about Posit + Python tools? Join our email list.

Great Tables is a fantastic Python library that lets you create beautiful display tables. This means transforming a raw data structure, like a Polars DataFrame, into a formatted, styled, beautified table suitable for reports and publishing insights.

You can get started with a single line of code:

import polars as pl
import polars.selectors as cs
from great_tables import GT, loc, style

coffee_sales = pl.read_ndjson("https://raw.githubusercontent.com/posit-dev/great-tables/4a11db5692a6e223b108dfcb73b39885652ccefb/docs/examples/_data/coffee-sales.ndjson")

GT(coffee_sales)

iconproductrevenue_dollarsrevenue_pctprofit_dollarsprofit_pctmonthly_sales
grinder.pngGrinder904500.00.03567960.00.04[521, 494, 596, 613, 667, 748, 765, 686, 607, 594, 568, 751]
moka-pot.pngMoka pot2045250.00.07181080.00.01[4726, 4741, 4791, 5506, 6156, 6619, 6868, 6026, 5304, 4884, 4648, 6283]
cold-brew.pngCold brew288750.00.01241770.00.02[244, 249, 438, 981, 1774, 2699, 2606, 2348, 1741, 896, 499, 244]
filter.pngFilter404250.00.0170010.00.0[2067, 1809, 1836, 2123, 2252, 2631, 2562, 2367, 2164, 2195, 2070, 2744]
drip-machine.pngDrip machine2632000.00.091374450.00.09[2137, 1623, 1971, 2097, 2580, 2456, 2336, 2316, 2052, 1967, 1837, 2328]
aeropress.pngAeroPress2601500.00.091293780.00.09[6332, 5199, 6367, 7024, 7906, 8704, 8693, 7797, 6828, 6963, 6877, 9270]
pour-over.pngPour over846000.00.03364530.00.02[1562, 1291, 1511, 1687, 1940, 2177, 2141, 1856, 1715, 1806, 1601, 2165]
french-press.pngFrench press1113250.00.04748120.00.05[3507, 2880, 3346, 3792, 3905, 4095, 4184, 4428, 3279, 3420, 3297, 4819]
cezve.pngCezve2512500.00.091969520.00.13[12171, 11469, 11788, 13630, 15391, 16532, 17090, 14433, 12985, 12935, 11598, 15895]
chemex.pngChemex3137250.00.11817680.00.06[4938, 4167, 5235, 6000, 6358, 6768, 7112, 6249, 5605, 6076, 4980, 7220]
scale.pngScale3801000.00.132910290.00.2[1542, 1566, 1681, 2028, 2425, 2549, 2569, 2232, 2036, 2089, 1693, 3180]
kettle.pngKettle756250.00.03617520.00.04[1139, 1023, 1087, 1131, 1414, 1478, 1456, 1304, 1140, 1233, 1193, 1529]
espresso-machine.pngEspresso Machine8406000.00.293636440.00.25[686, 840, 618, 598, 2148, 533, 797, 996, 1002, 668, 858, 2577]
NoneTotal29448500.01.014793150.01.0None

However, we believe that effective display tables go beyond the default with:

  • A structure that makes them easy to read
  • Well-formatted values to make data understandable
  • Styling that draws the viewer’s attention to key takeaways

As “total fanatics about table display,” Michael Chow and Richard Iannone, the minds behind Great Tables, understand this deeply. In their latest video series, they walk through more advanced techniques to elevate your Great Tables with structure, formatting, and styling.

For instance, see how Great Tables code can transform our basic table:

Code
gt_leveled_up = (
    GT(coffee_sales)
    .tab_header(title="Coffee Equipment Sales for 2023")
    .tab_spanner(label="Revenue", columns=cs.starts_with("revenue"))
    .tab_spanner(label="Profit", columns=cs.starts_with("profit"))
    .cols_label(
        revenue_dollars="Amount",
        revenue_pct="Percent",
        profit_dollars="Amount",
        profit_pct="Percent",
        monthly_sales="Monthly Sales",
    )
    .fmt_currency(columns=cs.ends_with("dollars"), use_subunits=False)
    .fmt_percent(columns=cs.ends_with("pct"), decimals=0)
    .tab_style(
        style=style.fill(color="aliceblue"),
        locations=loc.body(columns=cs.starts_with("revenue")),
    )
    .tab_style(
        style=style.fill(color="papayawhip"),
        locations=loc.body(columns=cs.starts_with("profit")),
    )
    .tab_style(
        style=style.text(weight="bold"),
        locations=loc.body(rows=pl.col("product") == "Total"),
    )
    .fmt_nanoplot(columns="monthly_sales", plot_type="bar")
    .fmt_image(
        columns="icon",
        path="~/rrr/posit-web/wp-content/themes/Posit/markdown-blogs/level-up-great-tables/img/",
    )
)

gt_leveled_up

Coffee Equipment Sales for 2023
iconproductRevenueProfitMonthly Sales
AmountPercentAmountPercent
Grinder$904,5003%$567,9604%
7650521494596613667748765686607594568751
Moka pot$2,045,2507%$181,0801%
6.87K04.73K4.74K4.79K5.51K6.16K6.62K6.87K6.03K5.30K4.88K4.65K6.28K
Cold brew$288,7501%$241,7702%
2.70K02442494389811.77K2.70K2.61K2.35K1.74K896499244
Filter$404,2501%$70,0100%
2.74K02.07K1.81K1.84K2.12K2.25K2.63K2.56K2.37K2.16K2.19K2.07K2.74K
Drip machine$2,632,0009%$1,374,4509%
2.58K02.14K1.62K1.97K2.10K2.58K2.46K2.34K2.32K2.05K1.97K1.84K2.33K
AeroPress$2,601,5009%$1,293,7809%
9.27K06.33K5.20K6.37K7.02K7.91K8.70K8.69K7.80K6.83K6.96K6.88K9.27K
Pour over$846,0003%$364,5302%
2.18K01.56K1.29K1.51K1.69K1.94K2.18K2.14K1.86K1.72K1.81K1.60K2.16K
French press$1,113,2504%$748,1205%
4.82K03.51K2.88K3.35K3.79K3.90K4.10K4.18K4.43K3.28K3.42K3.30K4.82K
Cezve$2,512,5009%$1,969,52013%
17.1K012.2K11.5K11.8K13.6K15.4K16.5K17.1K14.4K13.0K12.9K11.6K15.9K
Chemex$3,137,25011%$817,6806%
7.22K04.94K4.17K5.24K6.00K6.36K6.77K7.11K6.25K5.60K6.08K4.98K7.22K
Scale$3,801,00013%$2,910,29020%
3.18K01.54K1.57K1.68K2.03K2.42K2.55K2.57K2.23K2.04K2.09K1.69K3.18K
Kettle$756,2503%$617,5204%
1.53K01.14K1.02K1.09K1.13K1.41K1.48K1.46K1.30K1.14K1.23K1.19K1.53K
Espresso Machine$8,406,00029%$3,636,44025%
2.58K06868406185982.15K5337979961.00K6688582.58K
NoneTotal$29,448,500100%$14,793,150100%None

Ready to level up your tables? Explore the series details below, or start watching it here!

Great Tables 1: Structure, Format, and Style

Video Link | Workshop Repo

This video includes:

  • Examples of nicely formatted tables
  • An introduction to the display table workflow:
    • Structure for adding pieces like adding a title, column spanners, cleaning up column labels, creating row labels (stub), and grouping rows
    • Format for cleaning up the values within the data cells
    • Style for customizing the visual appearance of the table
  • Other exciting features that enhance table display, such as nanoplots and images

Great Tables 2: Introducing Units Notation

Video Link | Workshop Repo

This video includes:

  • An introduction to unit notation and syntax
  • Formatting methods
  • Information on how to handle missing numbers
  • Instructions on hiding columns

Great Tables 3: Data Color and Polishing

Video Link | Workshop Repo

This video includes:

  • Methods to transform a “wall of numbers” into a visually insightful heat map
  • How to use Markdown for formatting
  • Polars DataFrames and convenient column selectors
  • Resources for further learning

Continue your Great Tables journey

We hope that you enjoy Michael and Rich’s video series! The fun doesn’t have to stop here.

Isabella Velásquez's head shot

Isabella Velásquez

Sr. Product Marketing Manager at Posit, PBC
Isabella is a content strategist, data enthusiast, and author. Her goal is to drive engagement around all the awesome things happening at Posit.