Py.Cafe

giselle.pomodor/

streamlit-aggrid-example

Interactive DataGrid with AgGrid in Streamlit

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid, GridOptionsBuilder

# Create a sample dataframe
data = {
    'Name': ['Alice', 'Bob', 'Charlie', 'David'],
    'Age': [24, 27, 22, 32],
    'City': ['New York', 'Los Angeles', 'Chicago', 'Houston']
}
df = pd.DataFrame(data)

# Set up the page
st.title("Streamlit AgGrid Example")
st.write("This is an example of displaying a dataframe using st_aggrid.")

# Configure AgGrid options
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_pagination()
gb.configure_default_column(groupable=True)
grid_options = gb.build()

# Display the dataframe using AgGrid
AgGrid(df, gridOptions=grid_options)