forked from PablocFonseca/streamlit-aggrid-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0_Getting_started.py
More file actions
73 lines (51 loc) · 1.32 KB
/
Copy path0_Getting_started.py
File metadata and controls
73 lines (51 loc) · 1.32 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import streamlit as st
from st_aggrid import AgGrid
import pandas as pd
try:
st.set_page_config(layout="wide")
except Exception:
pass
st.markdown("# Getting Started with AgGrid")
st.markdown(
"""
## Instalation
Install streamlit-aggrid using pip or any package manager you prefer. Package is hosted on PyPi.
```
pip install streamlit-aggrid
```
"""
)
st.markdown(
"""
## Simple use
The simplest way to use the grid is to pass a pandas Dataframe to AgGrid call.
Grid will infer column names and data types from the dataframe and render.
The examplle below renders numbers right aligned and formats iso date columns.
```python
from st_aggrid import AgGrid
import pandas as pd
df = pd.read_json("https://www.ag-grid.com/example-assets/olympic-winners.json")
grid_return = AgGrid(df)
```
"""
)
@st.cache_data
def get_data():
return pd.read_json("https://www.ag-grid.com/example-assets/olympic-winners.json")
df = get_data()
tabs = st.tabs(
["Grid", "Infered GridOptions", "Returned AgGrid Data", "Trigger Event Data"]
)
with tabs[0]:
grid_return = AgGrid(df)
with tabs[1]:
st.write(grid_return.grid_options)
with tabs[2]:
st.write(grid_return.data)
st.markdown(
"""
## Grid Return
Grid return is an AgGridReturn object with props below:
"""
)
st.write(grid_return)