How to hide the first column in dataframe


I tried to drop, but df.drop seems to work only on the “regular” columns. Also tried, but no effect.

Want to hide that incrementing number first column when you do st.write(). How to do that?


Hi! I think this documentation covers your question: Hide row indices when displaying a dataframe - Streamlit Docs

Hope it helps!

1 Like


Oh I see. So it’s not as straight forward as I thought.

The example worked, it hid the values. But not the column itself. So there’s a blank column with no values, like this:

|      | col1  |col2   |
|      | aa    |bb     |
|      | cc    |dd     |


That’s weird, for me it looks exactly as in the documentation.
Maybe update the streamlit version?

Can you share the dataframe (first 5 rows) and code you’re using?

here goes:

   records = [{'tt': 'abc', 'xx': 'xyz'}, {'tt': '111', 'xx': '222'}]   
   df = pd.DataFrame(records)

   # CSS to inject contained in a string
   hide_dataframe_row_index = """
            .row_heading.level0 {display:none}
            .blank {display:none}
   st.markdown(hide_dataframe_row_index, unsafe_allow_html=True)



hello ,

i looked at the example again and so it seems, st.dataframe will show that blank column.

st.table will remove it.

it is what it is. :slight_smile:

thank you!

1 Like