Streamlit Common Issues

Sub-skill of streamlit: Common Issues.

vamseeachanta 5405636 839 B Updated

File contents

Common Issues

Common Issues

Issue: App reruns on every interaction

# Use forms to batch inputs
with st.form("my_form"):
    input1 = st.text_input("Input")
    submit = st.form_submit_button()

Issue: Slow data loading

# Add caching
@st.cache_data(ttl=3600)
def load_data():
    return pd.read_csv("large_file.csv")

Issue: Memory issues with large files

# Use chunking
@st.cache_data
def load_large_file(path, nrows=10000):
    return pd.read_csv(path, nrows=nrows)

Issue: Widget state lost on rerun

# Persist in session state
if "value" not in st.session_state:
    st.session_state.value = default_value

# Use key parameter
st.text_input("Name", key="user_name")

vamseeachanta/workspace-hub/tree/main/.agents/skills/_archive/data/analysis/streamlit/common-issues commit 54056361f8

Frequently asked questions

npx skillmds@latest add vamseeachanta/streamlit-common-issues