great-tables0.14.0
Published
Easily generate information-rich, publication-quality tables from Python.
pip install great-tables
Package Downloads
Project URLs
Requires Python
>=3.9
Dependencies
- htmltools
>=0.4.1
- commonmark
>=0.9.1
- importlib-metadata
- typing-extensions
>=3.10.0.0
- numpy
>=1.22.4
- Babel
>=2.13.1
- importlib-resources
- great-tables
[extra]; extra == "all"
- great-tables
[dev]; extra == "all"
- great-tables
[dev-no-pandas]; extra == "dev"
- pandas
; extra == "dev"
- black
; extra == "dev-no-pandas"
- jupyter
; extra == "dev-no-pandas"
- griffe
==0.38.1; extra == "dev-no-pandas"
- polars
; extra == "dev-no-pandas"
- pre-commit
==2.15.0; extra == "dev-no-pandas"
- pyarrow
; extra == "dev-no-pandas"
- pyright
>=1.1.244; extra == "dev-no-pandas"
- pytest
>=3; extra == "dev-no-pandas"
- pytest-cov
; extra == "dev-no-pandas"
- shiny
; extra == "dev-no-pandas"
- syrupy
; extra == "dev-no-pandas"
- quartodoc
>=0.8.1; python_version >= "3.9" and extra == "dev-no-pandas"
- selenium
>=4.18.1; extra == "extra"
- Pillow
>=10.2.0; extra == "extra"
With Great Tables anyone can make wonderful-looking tables in Python. The philosophy here is that we can construct a wide variety of useful tables by working with a cohesive set of table components. You can mix and match things like a header and footer, attach a stub (which contains row labels), arrange spanner labels over top of the column labels, and much more. Not only that, but you can format the cell values in a variety of awesome ways.
It all begins with table data in the form of a Pandas or Polars DataFrame. You then decide how to compose your output table with the elements and formatting you need for the task at hand. Finally, the table is rendered by printing it at the console, including it in an notebook environment, or rendering it inside a Quarto document.
The Great Tables package is designed to be both straightforward yet powerful. The emphasis is on simple methods for the everyday display table needs (but power when you need it). Here is a brief example of how to use Great Tables to create a table from the included sp500
dataset:
from great_tables import GT
from great_tables.data import sp500
# Define the start and end dates for the data range
start_date = "2010-06-07"
end_date = "2010-06-14"
# Filter sp500 using Pandas to dates between `start_date` and `end_date`
sp500_mini = sp500[(sp500["date"] >= start_date) & (sp500["date"] <= end_date)]
# Create a display table based on the `sp500_mini` table data
(
GT(sp500_mini)
.tab_header(title="S&P 500", subtitle=f"{start_date} to {end_date}")
.fmt_currency(columns=["open", "high", "low", "close"])
.fmt_date(columns="date", date_style="wd_m_day_year")
.fmt_number(columns="volume", compact=True)
.cols_hide(columns="adj_close")
)
There are ten datasets provided by Great Tables: countrypops
, sza
, gtcars
, sp500
, pizzaplace
, exibble
, towny
, metro
, constants
, and illness
.
All of this tabular data is great for experimenting with the functionality available inside Great Tables and we make extensive use of these datasets in our documentation.
Beyond the methods shown in the simple sp500
-based example, there are many possible ways to create super-customized tables. Check out the documentation website to get started via introductory articles for making Great Tables. There's a handy Reference section that has detailed help for every method and function in the package.
Let's talk about how to make Great Tables! There are a few locations where there is much potential for discussion.
One such place is in GitHub Discussions. This discussion board is especially great for Q&A, and many people have had their problems solved in there.
Another fine venue for discussion is in our Discord server. This is a good option for asking about the development of Great Tables, pitching ideas that may become features, and sharing your table creations!
Finally, there is the X account. There you'll find posts about Great Tables (including sneak previews about in-development features) and other table-generation packages.
These are all great places to ask questions about how to use the package, discuss some ideas, engage with others, and much more!
INSTALLATION
The Great Tables package can be installed from PyPI with:
$ pip install great_tables
If you encounter a bug, have usage questions, or want to share ideas to make this package better, please feel free to file an issue.
Code of Conduct
Please note that the Great Tables project is released with a contributor code of conduct.
By participating in this project you agree to abide by its terms.
š License
Great Tables is licensed under the MIT license.
Ā© Posit Software, PBC.
šļø Governance
This project is primarily maintained by Rich Iannone and Michael Chow. Other authors may occasionally assist with some of these duties.