streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

st.dataframe / st.table new parameter: hide_header, hide_index for column headers

Open davidsanchez222 opened this issue 1 year ago • 9 comments

Checklist

  • [X] I have searched the existing issues for similar feature requests.
  • [X] I added a descriptive title and summary to this issue.

Summary

st.dataframe parameter -> hide_header: bool | None = None. Just like hide_index, but for the column headers of a pd.DataFrame. Useful for displaying just rows extracted from pd.DataFrame instances.

Why?

I want to be able to take a row from a dataframe and render it in my streamlit app. I want to have a lot of separate rows rendered separately, but near each other, so having a column header each time would be redundant. The only solution to this as seen in this screenshot is to style the dataframe within pandas and then render the html string of the dataframe. This is hacky and does not get the UI styles and functionality that a st.dataframe object would. Also, pandas.Styler has bugs and it adds trailing zeros to my floating point values.

Screenshot 2024-03-04 at 3 33 35 PM

Two discussions have been made for this topic and the suggest the hacky html method: https://discuss.streamlit.io/t/hoe-create-table-without-header/23822 https://discuss.streamlit.io/t/st-dataframe-remove-the-header-row/49751

How?

How could I go about adding this feature?

Additional Context

No response

davidsanchez222 avatar Mar 04 '24 20:03 davidsanchez222

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Views

github-actions[bot] avatar Mar 04 '24 20:03 github-actions[bot]

For everyone seeing/upvoting this: please make sure to describe your exact use case here. If we see good use cases, that will help us prioritize this feature!

jrieke avatar Mar 05 '24 18:03 jrieke

This would be pretty useful specially when having to display multiple tables on the same page and trying to save screen real estate. The header takes up a bunch of space and sometimes it's not needed.

ds7608 avatar Jul 12 '24 16:07 ds7608

I am showing a content of dataframe which consists of key/value fields of various information. I am using st.table / st.dataframe to dump the content but I wish there is a way to hide the column headers as they do not add any values to the users.

shayashi-aam avatar Nov 15 '24 17:11 shayashi-aam

I want to use column_config.LineChartColumn cell below an st.metric and with the row title is looking really ugly. I tried to replicate the minimalist look of the line_chart in column_config with the regular line_chart component but it was impossible (hide axis, small factor, etc)

smtx avatar Dec 01 '24 11:12 smtx

@smtx for your use cases, we actually want to add sparklines to st.metric soon!

jrieke avatar Dec 02 '24 03:12 jrieke

https://github.com/glideapps/glide-data-grid/issues/1012

@jrieke I opened an issue on the glide data grid project (the component used to render st.dataframe) to hide the header row. If progress is made and the feature is added, would those changes be pulled into new versions of streamlit? Or is the version of glide-data-grid that the project uses unchanging?

Assuming the functionality is implemented on the side of glide-data-grid, the next steps would be update the python logic to include a hide_header flag, update the column config types, and update the protobuf that is sent to the frontend (i think that's how it works just from reading the code. i might be wrong)

What is your opinion? This issue got 18 likes since I made it back in March and I am still very eager to have this feature in a personal project. Should I go forward with making a PR?

davidsanchez222 avatar Dec 28 '24 19:12 davidsanchez222

I am rendering a transposed data frame and the default numeric index has become the column headers

craigh1015 avatar Apr 05 '25 02:04 craigh1015

This feature would be useful for displaying small tables. I have a few large tables and in my initial view, I show a summary with just 2 or 3 columns from the table. The user then has the option to view the full table. In case of the summary view, column headers are self evident and hence the ability to hide them would be useful.

Example:

Recently joined employees:

Employee name Designation
John Doe Vice President - Technology
Jane Doe Vice President - Marketing

View full list

Top holdings

Stock Quantity Value
MSFT 23 $2300
AAPL 36 $4500

View full list

In these cases, showing the header is not really necessary

gouravkr avatar Jun 05 '25 06:06 gouravkr