St.dataframe remove the header row


Iโ€™m looking to remove the header row at the top of the st.dataframe object. Iโ€™d be happy with st.table with the header row removed aswell, as the aim is a small data box with some important values in.

Example Code

st.dataframe(pd.DataFrame(["Intercept","Lower Confidence Limit at", "Upper Confidence Limit at"],[1,2,3]).values)

Expected behaviour

Create a table type object to display inforamtion without the useless header row

Actual Behaviour

No matter the chosen vlaues for st.dataframe or st.table a header row is generated whether column names are given or not and it looks very scruffy.

I donโ€™t think you can do that using streamlit functions. But you can generate HTML and display it with total control (but with more effort and no interactivity).

import pandas as pd
import streamlit as st
import streamlit.components.v1 as components

data = pd.DataFrame(["Intercept","Lower Confidence Limit at", "Upper Confidence Limit at"],[1,2,3])

Customize it to you heartโ€™s content by adding CSS.

1 Like

Yes I did something similar to this in the end using pd.styler.to_html() and using the arguments from that to delete the header/index and do some cell formatting aswell.

d1 = pd.DataFrame({"":["some text"]," ":["some more text"]}
st.markdown(**{'color': '#FF0000','font-weight':'bold'}.hide(axis = 0).hide(axis = 1).to_html(), unsafe_allow_html = True)

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