Can't edit list use st.experimental_data_editor

I can’t edit list in “person” and “location” column. Datatype=object. Can you help me, please?


articledf[[‘person’, ‘location’]] = articledf[‘description’].apply(lambda x: pd.Series(extract_entities(x)))
st.write(articledf.dtypes)
edited_df=st.experimental_data_editor(articledf )

Not all data types are supported yet. I also cannot edit date entries and that is listed as a “coming soon” item. The interesting thought is that all these cell editors are like individual widgets nested inside the data editor. Editing a list inside a cell of a data editor would be like nesting a data editor inside a data editor. Hence, I’m not sure where their thoughts are on such a thing. You may need to convert your lists to strings to edit them with the current data editor and do some extra manipulations to handle that.

As an example, I cannot edit columns ‘A’ and ‘B’ in this case:

import streamlit as st
import pandas as pd
from datetime import date

df = pd.DataFrame({
    'A':([1],[2],[3]),
    'B':(date(2020,1,1),date(2020,2,1),date(2020,3,1)),
    'C':(1,2,3),
    'D':('1','2','3')
})

st.experimental_data_editor(df)

The release blog post does say:

Support for additional data types. Let your users edit lists, tuples, sets, dictionaries, NumPy arrays, or Snowpark and PySpark dataframes. Most types are returned in their original format.

However, I think that means that you can pass lists and tuples as the base for populating the data editor, rather than editing such elements within a column of a dataframe.

It probably makes sense to update the documentation to clarify exactly which data types are and aren’t supported for editing with each release.

Pinging @jrieke

2 Likes

Oh good catch, sorry we didn’t document this anywhere! Yes, certain data types are not editable yet but we want to support most of them at some point. I’ll add a note to our docs (but this will only appear with the next release I think).

The interesting thought is that all these cell editors are like individual widgets nested inside the data editor.

Very good intuition :wink: We will release a feature in the next release where you can configure columns (e.g. change their type, set them as editable or not, etc) and that will pick up exactly that idea that most cells work relatively similar to widgets.

However, I think that means that you can pass lists and tuples as the base for populating the data editor, rather than editing such elements within a column of a dataframe.

Correct.

Forgot to add: We also just added a little icon to the column header that lets you differentiate between columns that are editable and ones that are not, see below. Will also come out with next release!

CleanShot 2023-05-08 at 18.28.29

1 Like

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