I have built a streamlit app using streamlit version 1.26.0(Working with an old version because of snowflake limitation), when st.dataframe data is updated to fewer number of rows than the previous, it is throwing “Error: Row index is out of range: 42” in the browser console. UI is displaying the updated data fine but the browser console is filled with these errors. I would appreciate any suggestion to fixing this issue. Below is the sample code:
import streamlit as st
import pandas as pd
import numpy as np
def update_rows():
st.session_state["data"] = pd.DataFrame(
np.random.randn(10, 20),
columns=('col %d' % i for i in range(20)))
if "data" not in st.session_state:
st.session_state["data"] = pd.DataFrame(
np.random.randn(50, 20),
columns=('col %d' % i for i in range(20)))
st.dataframe(st.session_state["data"])
st.button("Reduce rows", on_click=update_rows)
Sample Error:
main.a097c1ce.js:2 Error: Row index is out of range: 42
at e.value (main.a097c1ce.js:2:862670)
at 6402.32e1ae22.chunk.js:1:29411
at 3868.e86a14af.chunk.js:1:349447
at 3868.e86a14af.chunk.js:1:291362
at 3868.e86a14af.chunk.js:1:250447
at Cn (3868.e86a14af.chunk.js:1:264082)
at 3868.e86a14af.chunk.js:1:250090
at En (3868.e86a14af.chunk.js:1:264252)
at xn (3868.e86a14af.chunk.js:1:249539)
at Dn (3868.e86a14af.chunk.js:1:262595)