Hello there 👋

Thanks for stopping by! We use cookies to help us understand how you interact with our website.

By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.

Configure a list column in st.dataframe or st.data_editor.

This is the default column type for list-like values. This command needs to be used in the column_config parameter of st.dataframe or st.data_editor. When used with st.data_editor, users can freely type in new options and remove existing ones.

Note

Editing for non-string or mixed type lists can cause issues with Arrow serialization. We recommend that you disable editing for these columns or convert all list values to strings.

Function signature[source]

st.column_config.ListColumn(label=None, *, width=None, help=None, pinned=None, disabled=None, required=None, default=None)

Parameters

label (str or None)

The label shown at the top of the column. If this is None (default), the column name is used.

width ("small", "medium", "large", int, or None)

The display width of the column. If this is None (default), the column will be sized to fit the cell contents. Otherwise, this can be one of the following:

  • "small": 75px wide
  • "medium": 200px wide
  • "large": 400px wide
  • An integer specifying the width in pixels

If the total width of all columns is less than the width of the dataframe, the remaining space will be distributed evenly among all columns.

help (str or None)

A tooltip that gets displayed when hovering over the column label. If this is None (default), no tooltip is displayed.

The tooltip can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the body parameter of st.markdown.

pinned (bool or None)

Whether the column is pinned. A pinned column will stay visible on the left side no matter where the user scrolls. If this is None (default), Streamlit will decide: index columns are pinned, and data columns are not pinned.

disabled (bool or None)

Whether editing should be disabled for this column. If this is None (default), Streamlit will enable editing wherever possible.

If a column has mixed types, it may become uneditable regardless of disabled.

required (bool or None)

Whether edited cells in the column need to have a value. If this is False (default), the user can submit empty values for this column. If this is True, an edited cell in this column can only be submitted if its value is not None, and a new row will only be submitted after the user fills in this column.

default (Iterable of str or None)

Specifies the default value in this column when a new row is added by the user. This defaults to None.

Examples

import pandas as pd
import streamlit as st

data_df = pd.DataFrame(
    {
        "sales": [
            [0, 4, 26, 80, 100, 40],
            [80, 20, 80, 35, 40, 100],
            [10, 20, 80, 80, 70, 0],
            [10, 100, 20, 100, 30, 100],
        ],
    }
)

st.data_editor(
    data_df,
    column_config={
        "sales": st.column_config.ListColumn(
            "Sales (last 6 months)",
            help="The sales volume in the last 6 months",
            width="medium",
        ),
    },
    hide_index=True,
)
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.