st.column_config.MultiselectColumn values are not saved when the "data" is empty in data_editor

Hello, I was trying to use the new st.column_config.MultiselectColumn component, it works well as used in the demo code. However when you try to use it with with an empty dataframe (only columns names) for the “data’ parameter in the st.data_editor function it looks like the selected values for the multiselect are not saved.

The code:

data_df = pd.DataFrame(

columns=\[

“category”, “test”

\]

)

st.write(‘The editable dataframe:’)

edited_data = st.data_editor(

data_df,

num_rows="dynamic",

column_config={

“test”: st.column_config.TextColumn(‘test’),

“category”: st.column_config.MultiselectColumn(

“App Categories”,

        help="The categories of the app",

        options=\[

“exploration”,

“visualization”,

“llm”,

        \],

    ),

},

)

st.write(‘Print of the editable dataframe after modification:’)

st.write(edited_data)

Results:

This behavior only apply to the Multiselect. Other type are working well

Summary

This text will be hidden

Hello @Hedi1 ,

In fact it raise an error in

.venv/lib/python3.13/site-packages/streamlit/elements/widgets/data_editor.py at line 216:

commenting the error and writing “pass”, your code works

Maybe you should report this as a bug.

Have a nice week-end.

Jp

Hello @Jean_Pierre,

Thanks for your help, I did report it. Feel free to add your solution to help streamlit devs:

1 Like