Introducing column config βš™οΈ

Take st.dataframe and st.data_editor to the next level!

Posted in Product, June 22 2023

One of the biggest pain points you've told us about repeatedly is dataframe customization.

Data wrangling is at the core of your work, and you've long needed more capabilities than those offered by st.dataframe and st.data_editor.

Here are some of the things you told us you need to do:

We heard you! That's why in Streamlit 1.23, we're excited to introduce…

Column configuration! πŸŽ‰

Now you can customize all columns in st.dataframe and st.data_editor, so your tables look and feel exactly the way you need. Want to see it? Check out our demo app or read below.

Plus, we've moved st.data_editor out of experimental! 🎈

A small example

The main star of the show is the new column_config parameter. We added it to both st.dataframe and st.data_editor.

It's a dictionary that maps column types to their configuration:

st.data_editor(
    df,
    column_config={
        "column 1": "Name",  # change the title
        "column 3": st.column_config.ImageColumn("Avatar"),
        "column 4": st.column_config.NumberColumn(
            "Age", min_value=0, max_value=120, format="%d years"
        ),
        "column 8": st.column_config.LineChartColumn(
            "Activity (1 year)", y_min=0, y_max=100
        ),
    },
)

Taking this a bit further, you can create powerful tables like this:

Try playing with it:

  • Scroll to the right to see some beautiful charts βœ¨πŸ“ˆ
  • Double-click on links to open them πŸ”—
  • Double-click on a cell to edit it and see input validation features in action ✍️

As you can see in the code, we also introduced new classes for different column types under the st.column_config namespace. In fact, there are 14 different column types that cover everything from text over images to sparkline charts! Each of these classes lets you set additional parameters to configure the display and editing behavior of the column.

Have a look at them on our new docs page! 🎈

To learn more about the column_config parameter itself, check out the API references for  st.dataframe and st.data_editor.

More parameters

Want to hide the index column without delving into column configuration? We've got you covered!

In addition to the column_config parameter, we added a few more parameters that allow you to perform common operations more quickly:

  • hide_index=True lets you hide the index column
  • column_order=["col 3", "col2"] lets you set the order in which columns show up
  • disabled=["col1", "col2"] lets you turn off editing for individual columns on st.data_editor

Read more about these parameters on the API docs for st.dataframe and st.data_editor.

Wrapping up

We're excited to see what you'll build with this new feature. Please share your examples on Twitter and the forum! Head over to our example app to get some inspiration. And if you have more feature requests for dataframes (and beyond), let us know on GitHub.

Happy Streamlit-ing! 🎈


This is a companion discussion topic for the original entry at https://blog.streamlit.io/introducing-column-config
5 Likes

Is wrapping long text data in a column possible with this approach . i do not see any reference to text wrapping in the properties. Am looking for a way to display and edit long text in a grid format which can then be later saved to a Google sheet with formatting of the text retained . Any suggestions?

No way to do this today but there’s a feature request for it on GitHub, please feel free to upvote and leave comments! :slight_smile:

1 Like

Upvoted! and i have been looking at other solutions that do work - for anyone on here - take a look at this - its not using st.dataframe or st.data_editor - but it for text display this is pretty effective How to display long text in Streamlit dataframes with automatic line breaks?

1 Like

Hi, thanks this looks really good.
Is it possible to finetune ListColumn, for ex each value in a list would either red or green based on their value?

Not yet :frowning: But you can create a feature request for this :slight_smile:

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