Streamlit st.data_editor Error in Cell Creation

ISSUE: The st.data_editor returns an error when num_rows is set to “dynamic”:

Error during cell creation.

This should never happen. Please report this bug. 
Error: Error: Row index is out of range: 4

To recreate the error, just visit the documentation page for st.data editor and try adding a new row: st.data_editor - Streamlit Docs

My browser is Opera GX if that info is needed. Win10 64bit and I use streamlit cloud

Hi @Shiro,

Thanks for sharing this question.

Is this the code snippet you’re using?

import streamlit as st
import pandas as pd

df = pd.DataFrame(
    [
       {"command": "st.selectbox", "rating": 4, "is_widget": True},
       {"command": "st.balloons", "rating": 5, "is_widget": False},
       {"command": "st.time_input", "rating": 3, "is_widget": True},
   ]
)
edited_df = st.data_editor(df, num_rows="dynamic")

favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
st.markdown(f"Your favorite command is **{favorite_command}** 🎈")

I wasn’t able to reproduce this error using this code snippet or the embedded app in the docs (I’ve deployed the app here to try to reproduce). I also downloaded Opera GX and unfortunately wasn’t able to reproduce it with that browser, either.

Does this happen every time you try adding a new row, or only intermittently?

Hi,

I have just got the error by combining st.data_editor with st.expander.

The error can be reproduced by running the code below and then doing the following:

  1. expand the st.expander
  2. add an empty row to the st.ddata_editor
  3. collapse the st.expander
  4. expand the st.expander once again

Code:

import pandas as pd
import streamlit as st
  
with st.expander('expander'):
    df = pd.DataFrame(
        [
        {"command": "st.selectbox", "rating": 4, "is_widget": True},
        {"command": "st.balloons", "rating": 5, "is_widget": False},
        {"command": "st.time_input", "rating": 3, "is_widget": True},
    ]
    )
    st.data_editor(df, num_rows="dynamic")
1 Like

Hey @MaliMi,

Thanks for sharing this! I was able to reproduce this locally.

Do you mind sharing this in our GitHub Issues?

Sorry for late reply. I was on holiday from Thursday.
Anyway, the issue seems to be similar to: https://github.com/streamlit/streamlit/issues/7458, so I just added thumbs up to the initial post.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.