Hello!
Sorry for the long post. I have developed a dashboard to analyze some media expense variables and their corresponding effect on sales. One section of the dashboard deals with the simulation of media effects based on changing the expense of any of the media variables. For this part of the project, I have used the st.data_editor().
Initially I had a st.data_editor() widget with the values of the expense of each media channel per week and their corresponding effect on sales. I also included a plotly graph below de data_editor, showing the expense in one y-axis and the effect on sales in a second y-axis while the x-axis represented the date in weeks.
I placed the data editor widget inside a streamlit form so that I could make all changes required to the expense columns and refresh the calculations for the effects in one shot by clicking on the āSubmitā button. I noticed that although the graph would update, the values for the effects in the data editor remained the same. I decided to move the effects columns to a different widget and used the st.dataframe() for this in a separate column, next to the data editor. Althought visually not ideal, this worked. At this point I had the data editor widget inside a form with only the expense columns, a dataframe widget with the effects columns right next to the data editor in a separate column, and a plotly graph below both tables with the expense and effect per week.
However, last Thursday night I left everything working and on Friday morning, when I refreshed the dashboard got the following REACT related error, which I have no clue what it means and canĀ“t find anything online about it and how it related to Streamlit:
Error: Minified React error #185; visit Minified React error #185 ā React for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at rc (http://localhost:8501/static/js/main.1661a802.js:2:2270081)
at ns (http://localhost:8501/static/js/main.1661a802.js:2:2235374)
at http://localhost:8501/static/js/4253.ffc51ffe.chunk.js:2:148947
at http://localhost:8501/static/js/4253.ffc51ffe.chunk.js:2:278168
at http://localhost:8501/static/js/4253.ffc51ffe.chunk.js:2:221213
at http://localhost:8501/static/js/4253.ffc51ffe.chunk.js:2:221428
at http://localhost:8501/static/js/4253.ffc51ffe.chunk.js:2:217543
at http://localhost:8501/static/js/4253.ffc51ffe.chunk.js:2:217818
at ol (http://localhost:8501/static/js/main.1661a802.js:2:2260597)
at yl (http://localhost:8501/static/js/main.1661a802.js:2:
I started to simplify the code and eventually removed the streamlit form used to update the data editor and now it seems to be working again, but this is not what I want. I would prefer to have the data editor inside a form.
On a somewhat separate issue, I am also finding myself having trouble performing a āreset all columnsā in the data editor, meaning, going back to the original expense values. In fact, I have tried to debug this issue by printing the values of the original dataframe (which is a parameter of the st.data_editor()) immediately before executing the data editor, and it seems that the data editor does not take the original dataframe as parameterā¦ let me show what Ć mean by including the following code:
st.dataframe(df_sim_output) # Already updated dataframe with the original values from session state
de_df_sim_output = st.data_editor(
data = df_sim_output, # This parameter, which should be taking the df above, seems to be taking something else
hide_index=True,
use_container_width=True,
column_config=col_config,
column_order=[date_col.title()] + ['Tv', 'Radio', 'Press'],
key='de_df_sim',
num_rows='fixed',
disabled=(col for col in df_sim_output.columns.to_list() if 'Total Effect' in col or col == date_col.title())
)
In the code above, st.dataframe(df_sim_output) shows the original expense values of the dataframe after clicking on a āreset allā buttom, while the de_df_sim_out data_editor shows the expense values used in the previous step before clicking the reset buttomā¦ how can this be if the df_sim_output immediately before executing de_df_sim shows the right values? Why is the data editor widget not taking the df_sim_output parameter correctly, and, more importantly, why am I getting that weird REACT error shown above when putting the data editor inside the streamlit form?
I am running this locally.
Streamlit version: 1.32
Python version: 3.12.0