This repo contains a source code for a Streamlit application that illustrates some tips and tricks for using AgGrid in Streamlit apps, as well as some non-AgGrid related hints.
Blog posts referenced this repo:
- Enhancing your Streamlit tables with AgGrid: advanced tips and tricks | Medium
- Tracking and Displaying Changes in the Streamlit App | Medium
Data source: https://data.fivethirtyeight.com/
import agstyler
from agstyler import PINLEFT, PRECISION_TWO
formatter = {
'player_name': ('Player', PINLEFT),
'team': ('Team', {'width': 80}),
'poss': ('Possessions', {'width': 110}),
'mp': ('mp', {'width': 80}),
'raptor_total': ('RAPTOR', {**PRECISION_TWO, 'width': 100}),
'war_total': ('WAR', {**PRECISION_TWO, 'width': 80}),
'pace_impact': ('Pace Impact', {**PRECISION_TWO, 'width': 120})
}
row_number = st.number_input('Number of rows', min_value=0, value=20)
data = agstyler.draw_grid(
df.head(row_number),
formatter=formatter,
fit_columns=True,
selection='multiple', # or 'single', or None
use_checkbox='True', # or False by default
max_height=300
)