Skip to content

MultiselectColumn: inhomogeneous array shape error when adding new row to data editor with multiple columns #12815

@Motunrayo244

Description

@Motunrayo244

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When using st.data_editor configured with a Multiselect column (column config → st.column_config.MultiselectColumn) and the data editor is dynamic and contains other columns, adding a new row that sets the multiselect column causes Streamlit to raise a ValueError

Reproducible Code Example

import pandas as pd
import streamlit as st

data_df = pd.DataFrame(
    {
        "category": [
            ["exploration", "visualization"],
            ["llm", "visualization"],
            ["exploration"],
        ],
        "is_active": [True, True, True],
        
    }
)

st.data_editor(
    data_df,
    hide_index=True,
    num_rows="dynamic",
    key="data_editor_key",
    column_config={
        "category": st.column_config.MultiselectColumn(
            "App Categories",
            help="The categories of the app",
            options=[
                "exploration",
                "visualization",
                "llm",
            ],
            color=["#ffa421", "#803df5", "#00c0f2"],
            format_func=lambda x: x.capitalize(),
        ),
        "is_active":st.column_config.CheckboxColumn(
            "Active", 
            help="Tick to include this app in the analysis.",
            default=True,
            required=True,
        )
    },
)

Steps To Reproduce

  1. Add a row to the data_editor
  2. Select at least one option from the multi select in App Categories

Expected Behavior

Add New row to the data editor with the selected values in the App Categories column

Current Behavior

Error Message:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.50.0
  • Python version: 3.11.13
  • Operating System: MacOs 15.5
  • Browser: Chrome

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.column_configRelated to column configuration functionalityfeature:st.data_editorRelated to the `st.data_editor` widgetpriority:P2Medium-high priority - fix within one monthstatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions