Is it possible to automatically insert a value set by code when adding a new row by using st.data_editor?
For example, created a st.data_editor with 2 lines. In the first column, there should always be an ascending number (1, 2, 3, etc.) instead of None. Is there any “nice” way to implement this?
Thanks for your help!
There is a
default parameter for all the editable column types here: st.column_config - Streamlit Docs
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
"widgets": ["st.selectbox", "st.number_input", "st.text_area", "st.button"],
"widgets": st.column_config.TextColumn("Widgets", default="st.")
This will add a
st. as the default value in every new row. Unfortunately, this can only be a static value currently and not something dynamic like an ascending number.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.