Hi
I´m new on this part, so bear with me.
I’ve honestly tried chat GPT but here it runs into a challenge it couldn’t handle.
Made other code by following an interesting review via the youtube channel Code is fun (Sven) and it works fine.
But to the code I now want to add streamlit_aggrid and despite several attempts I can’t get it to work. What is correct attribute?
Error code is as follows: (Know it’s wrong but tried with JSON, FORM_FILL and VALUE)
AttributeError: FULL
Traceback:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.__dict__)File "/Users/install/Library/Mobile Documents/com~apple~CloudDocs/TK iCloud Drive/TEST/Kunder/app.py", line 60, in <module>
data_return_mode=DataReturnMode.FULL
^^^^^^^^^^^^^^^^^^^File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py", line 789, in __getattr__
raise AttributeError(name) from None
Code snippet:
import pandas as pd
import streamlit as st
import streamlit.components.v1 as components
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode
st.set_page_config(page_title="Sales Dashboard", layout="wide")
df = pd.read_excel(
io='Kunder.xlsx',
engine='openpyxl',
sheet_name='Kunder',
skiprows=1,
usecols='A:G',
nrows=2000
)
# ----- SIDEBAR -----
st.sidebar.header("Please Filter Here:")
all_option = ["All"]
sales_rep = st.sidebar.selectbox(
"Select Sales_Rep:",
options=all_option + list(df["Sales_Rep"].unique()),
index=0
)
head_customer = st.sidebar.selectbox(
"Select Head_Customer_Name:",
options=all_option + list(df["Head_Customer_Name"].unique()),
index=0
)
if sales_rep == "All" and head_customer == "All":
df_selection = df.copy()
elif sales_rep != "All" and head_customer != "All":
df_selection = df.query("Sales_Rep == @sales_rep and Head_Customer_Name == @head_customer")
elif sales_rep == "All":
df_selection = df.query("Head_Customer_Name == @head_customer")
else:
df_selection = df.query("Sales_Rep == @sales_rep")
# Define AgGrid configuration
gb = GridOptionsBuilder.from_dataframe(df_selection)
gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc='sum', editable=True)
gridOptions = gb.build()
# Render AgGrid
components.html(
AgGrid(
df_selection,
gridOptions=gridOptions,
width='100%',
height='500px',
data_return_mode=DataReturnMode.FULL
).get_html(),
height=800
)