UPDATE: I found my error. Note Iām using ==, as opposed to just one =, when assigning the value.
Iām trying to update a dataframe with data captured from the data_editor.
Iām subsetting a āmainā dataframe to the rows I want to show in the streamlit app. I use data_editor to show them and allow for updating of boolean columns. I have set the key = ādata_editorā. Iām using a for loop to cycle through any data that was updated. Based on those that were updated Iām trying to update the āmainā dataframe.
Hereās the code Iām using to update the āmainā dataframe and then showing that subset. Iām showing the subset again on the screen for the purposes of testing. Iām thinking I should be seeing this subset with the updates made.
for key, value in st.session_state['data_editor']['edited_rows'].items():
forindex = key
print("key:", key, "value:", value)
for updtd_col, new_val in value.items():
print("\tUpdated Column:", updtd_col, "\tNew Value:", new_val)
print("\t\tIndex:", Inbox_Site_df.iloc[forindex]['fileref'])
Inbox_File_Level.loc[((Inbox_File_Level['site']== site_choice) & \
(Inbox_File_Level['date'] == delivery_choice) & \
(Inbox_File_Level['fileref'] == Inbox_Site_df.iloc[forindex]['fileref'])), updtd_col] == new_val
Inbox_File_Level.loc[(Inbox_File_Level['site']== site_choice) & (Inbox_File_Level['date'] == delivery_choice)]
In the above the updtd_col is the column indicated in the session state data_editor along with the new_val being the current value the user has selected. Hereās a screenshot of one item that was updated. You can see the name of the column here is āStep_1_Check_csvā and the new_val = True. The Index is being used to help narrow filter the āmainā df to the row that should be updated.
Let me know what more would be helpful to provide.