New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st.data_editor does not return added rows when dataframe from file #6995
Comments
Thank you Lukas. And in the debugger it looks like "index" has a different type ("Index" vs. "RangeIndex"), but I don't understand pandas well enough to know if this is significant. |
I now have an easy workaround in case others encounter this problem: |
@hEAkahEq Yep, that is indeed the issue here. If the index of the dataframe is not a RangeIndex, we cannot automatically insert this row into the dataframe without a non-None index value provided by the user. That is why the index column is also shown as editable. |
One aspect to improve here from UI perspective is that we set non-RangeIndex columns to |
What Pandas version do you use on your system? Is it solved if you update to the latest Pandas version? |
@LukasMasuch Thanks for looking into this. I updated Pandas from 2.0.2 to 2.0.3 and it does not appear to be fixed. |
Checklist
Summary
st.data_editor does not contain added rows when it is created out of a dataframe from a json loaded with st.file_uploader. The rows are visualized, but not accessible in the data_editor object.
A forum post on this issue can be found here: https://discuss.streamlit.io/t/adding-rows-in-st-data-editor-from-loaded-dataframe/46439
Saved_dataframe.txt
Reproducible Code Example
Steps To Reproduce
{"name": {"0": "0", "1": "1", "2": "2", "3": "3"}, "Type": {"0": null, "1": null, "2": null, "3": null}}
)a workaround to get the visualized data:
if st.session_state.loaded: fixed_df = pd.concat([edited_df, pd.DataFrame(st.session_state["demo_df"].get("added_rows"))]) else: fixed_df = edited_df st.write(fixed_df)
Expected Behavior
data_editor should behave the same no matter where the dataframe used to create it comes from.
Current Behavior
edited_df does not contain rows added in the GUI when it was created from a dataframe loaded via st.file_uploader
Is this a regression?
Debug info
Additional Information
No response
The text was updated successfully, but these errors were encountered: