Hello!
I am new to the community and this is my first post. I hope that I am posting in the right place and using the appropriate context.
I am wondering if it is possible to modify the value of a column in an editable data frame based on the user’s interaction with the ‘is_widget’ column.
from streamlit import session_state as ss, data_editor as de, rerun as rr
import pandas as pd
import streamlit as st
df = pd.DataFrame(
[
{'command': 'text1', 'value': 1, 'is_widget': True},
{'command': 'text2', 'value': 0, 'is_widget': False},
{'command': 'text3', 'value': 1, 'is_widget': True},
]
)
if 'start_df' not in ss:
ss.start_df = df
def update_values():
for i in range(len(st.session_state.start_df)):
st.session_state.start_df.at[i, 'value'] = int(st.session_state.start_df.at[i, 'is_widget'])
def main():
edited_df = de(ss.start_df)
if not ss.start_df.equals(edited_df):
ss.start_df = edited_df
update_values()
rr()
if __name__ == '__main__':
main()
Now on to the next phase…integrating this into my larger app! My main app also has an upload file functionality plus a few other functions to modify the uploaded data frame.