๐งฎย ย Great Tables
Submitted by Lukas Masuch
Summary
Render Great Tables objects in Streamlit. Great tables allows to implement wonderful-looking display tables in Python.
Functions
great_tables
Render a Great Tables object in Streamlit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table
|
'GT'
|
A Great Tables object. |
required |
width
|
int | Literal['stretch', 'content']
|
The width of the table. One of:
- |
'stretch'
|
Source code in src/streamlit_extras/great_tables/__init__.py
Import:
- You should add this to the top of your .py file
Examples
example
def example():
try:
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
table = (
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")
)
great_tables(table, width="stretch")
except ImportError:
st.warning(
"This example requires the `great_tables` package. "
"Install it with `pip install great-tables`."
)