Is there a way to specify column width for dataframe/table

Hi @knorthover

Streamlit can draw dataframes in two different ways:

  1. With st.dataframe(df), to show a scrollable / sortable / interactive table. This is what st.write and magic use behind the scenes.
  2. With st.table(df), to show a static table.

Both methods support dataframe Stylers, but as you found out they only support a subset of styles: only colors and display values. Which means we today ignore width settings in Stylers.

(BTW, I created a feature request for you here)

That said, between st.dataframe and st.table, only the former truncates columns at all. That is, st.table shows tables in their entirety: no truncation, no scrolling, just the whole table.

So a work-around for you would be to use st.table for now.

1 Like