Skip to main content

The Zen of Great Tables

Python has a well-known easter egg: import this prints The Zen of Python (PEP 20). Great Tables took inspiration from this and wrote its own Zen. And since it’s a Zen about tables, importing it in a notebook shows a great table:

import great_tables.this
The Zen of Great Tables
by the Great Tables crew, after Tim Peters's import this
Aphorism Embodied by Faithful to PEP 20
I Beautiful is better than printed at the console.
Beautiful is better than ugly.
opt_stylize()
0.69
69%
II A data table is input. A display table is output.
Explicit is better than implicit.
gtsave()
0.22
22%
III Simple is better than complex.
Simple is better than complex.
cols_hide()
1.00
100%
IV Complex is better than copying it into Excel.
Complex is better than complicated.
tab_style()
0.75
75%
V Flat is better than nested, unless it's under a spanner.
Flat is better than nested.
tab_spanner()
0.65
65%
VI Sparse is better than dense, but a nanoplot can be both.
Sparse is better than dense.
fmt_nanoplot()
0.67
67%
VII Readability counts, in every locale from af to zu.
Readability counts.
fmt_number()
0.55
55%
VIII Special cases aren't special enough to break the six components.
Special cases aren't special enough to break the rules.
tab_stub()
0.87
87%
IX Although opt_css() beats purity, provided you have those CSS skillz.
Although practicality beats purity.
opt_css()
0.50
50%
X Missing values should never pass silently.
Errors should never pass silently.
data_color()
0.79
79%
XI Unless explicitly sub_missing().
Unless explicitly silenced.
sub_missing()
0.75
75%
XII In the face of ambiguity, label your columns.
In the face of ambiguity, refuse the temptation to guess.
cols_label()
0.59
59%
XIII There should be one (and preferably only one) obvious way to make a table.
There should be one-- and preferably only one --obvious way to do it.
GT()
0.87
87%
XIV Although that way may not be obvious at first unless you're Rich.
Although that way may not be obvious at first unless you're Dutch.
md()
0.96
96%
XV Now is better than never.
Now is better than never.
fmt_datetime()
1.00
100%
XVI Although the 1949 Census Manual is often better than right now.
Although never is often better than *right* now.
fmt_roman()
0.77
77%
XVII If the table is hard to explain, add a footnote.
If the implementation is hard to explain, it's a bad idea.
tab_footnote()1
0.66
66%
XVIII If the table is easy to explain, it may be a great table.
If the implementation is easy to explain, it may be a good idea.
tab_header()
0.76
76%
XIX Bringing your own DataFrame is one honking great idea: let's do more of those!
Namespaces are one honking great idea -- let's do more of those!
GT(your_df)
0.73
73%
XX Left for Rich Iannone to write.
Faithfulness is difflib's similarity ratio between each aphorism and its PEP 20 original.
Originals: PEP 20, The Zen of Python. Remix: the Great Tables docs and blog.
1 See?

At the console, the import prints the aphorisms as plain text instead, just like import this does. To see the table from there, open it in your browser:

from great_tables.this import table

table().show()