Is it possible to use a button to adjust values in an editable dataframe

Summary

I am successfully using the editable dataframe, which is great. However, as well as alowing the user to click and edit a cell, I would like to implement a button so that when pressed, it will increment a set of values (say a single column) by a number (say 1).

Problem

My difficulty lies in passing these adjusted cells back to the dataframe. If I edit the dataframe directly, the editable dataframe object detects it had edited cells and overwrites them with the values which were manually input.

I have tried to workaround by changing the values in st.session_state.<editable_df_key>[โ€˜edited_cellsโ€™] but this is not preserved. I can see the changes in this object at the end of the script, but when the script reruns from the start, the changes I programatically made to the session_state seem to be overwritten.

Is there a way I can implement this type of functionality?

Thanks

Actually, Iโ€™ve realised I do not need to edit the edited_cells information and was able to make use of the responses here: Updating data in in editable dataframe (st.experimental_data_editor) - #8 by blackary

I just needed to act on the returned dataframe from the experimental_data_editor, update the values there and store back into the session state dataframe which I am using in the experimental_data_editor.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.