[소스코드]
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder
import pandas as pd
# 회사 데이터 구조를 DataFrame으로 변환
data = [
{"company": "Company A", "hq": "HQ 1", "team": "Team 1-1", "part": "Part 1-1"},
{"company": "Company A", "hq": "HQ 1", "team": "Team 1-1", "part": "Part 1-2"},
{"company": "Company A", "hq": "HQ 1", "team": "Team 1-1", "part": "Part 1-3"},
{"company": "Company A", "hq": "HQ 1", "team": "Team 1-2", "part": "Part 2-1"},
{"company": "Company A", "hq": "HQ 1", "team": "Team 1-3", "part": "Part 2-2"},
{"company": "Company A", "hq": "HQ 2", "team": "Team 2-1", "part": "Part 2-3"},
{"company": "Company A", "hq": "HQ 2", "team": "Team 2-2", "part": "Part 3-1"},
{"company": "Company B", "hq": "HQ 3", "team": "Team 3-1", "part": "Part 3-2"},
{"company": "Company B", "hq": "HQ 3", "team": "Team 3-2", "part": "Part 3-3"},
{"company": "Company B", "hq": "HQ 4", "team": "Team 4-1", "part": "Part 4-1"},
{"company": "Company B", "hq": "HQ 4", "team": "Team 4-2", "part": "Part 4-2"},
{"company": "Company B", "hq": "HQ 4", "team": "Team 4-3", "part": "Part 4-3"},
]
df = pd.DataFrame(data)
# Ag-Grid 설정
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_default_column(groupable=True)
gb.configure_column("company", rowGroup=True, hide=True)
gb.configure_column("hq", rowGroup=True, hide=True)
gb.configure_column("team", rowGroup=True, hide=True)
#gb.configure_column("part", rowGroup=True, hide=True)
gb.configure_column("part", header_name="Team", min_width=250)
gridOptions = gb.build()
st.header("Company Structure")
AgGrid(df, gridOptions=gridOptions, enable_enterprise_modules=True)
댓글