Introducing Great Tables: Delightful Table-Making in Python
Great Tables is a Python package that brings elegance and functionality to table creation. With Great Tables, users can construct visually appealing tables effortlessly, utilizing a cohesive set of table components. This tool allows for an array of elements, including headers, footers, row labels (stubs), column labels with spanner labels over them, and more. Moreover, it offers exceptional flexibility in formatting cell values.
The Essence of Table Creation
The process begins with table data structured as a Pandas or Polars DataFrame. Users then assemble their tables by selecting the necessary elements and formatting them according to their requirements. Once the design is complete, the table can be rendered on a console, integrated into a notebook environment, or included in a Quarto document for broader applications.
Simplicity Meets Power
Great Tables is engineered to strike a balance between simplicity and functionality. It addresses common table display needs with straightforward methods while offering advanced capabilities for more complex tasks. To illustrate its use, here is a simple example using a dataset called sp500
:
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")
)
Datasets
Great Tables comes with ten datasets: countrypops
, sza
, gtcars
, sp500
, pizzaplace
, exibble
, towny
, metro
, constants
, and illness
. These datasets provide ample opportunities for experimenting with the package's rich features and functionalities.
Getting Started
To dive into Great Tables, visit the documentation website. Here, you will find introductory articles and a comprehensive reference section with detailed descriptions of every method and function available.
Community and Support
Discover a vibrant community eager to discuss and explore Great Tables:
- GitHub Discussions: A platform for Q&A and problem-solving.
- Discord Server: Engage in discussions about the tool's development, share ideas for features, and showcase your table creations.
- X Account: Follow for updates, sneak previews of features in development, and insights into other table-generation packages.
Installation and Participation
To install Great Tables from PyPI, use:
$ pip install great_tables
Encountered a bug, have questions, or wish to propose improvements? Feel free to file an issue.
Governance and Conduct
The project is primarily maintained by Rich Iannone and Michael Chow, with contributions by other authors. It adheres to a code of conduct to ensure respectful and constructive interaction.
Great Tables is released under the MIT license and is a product of Posit Software, PBC. For more insights, engaging discussions, and opportunities for collaboration, delve into the world of Great Tables!