Hi,
I tried to drop, but df.drop seems to work only on the “regular” columns. Also tried df.style.hide_index(), but no effect.
Want to hide that incrementing number first column when you do st.write(). How to do that?
Thanks!
Hi,
I tried to drop, but df.drop seems to work only on the “regular” columns. Also tried df.style.hide_index(), but no effect.
Want to hide that incrementing number first column when you do st.write(). How to do that?
Thanks!
Hi! I think this documentation covers your question: Hide row indices when displaying a dataframe - Streamlit Docs
Hope it helps!
Hello,
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 |
Thanks!
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 = """
<style>
.row_heading.level0 {display:none}
.blank {display:none}
</style>
"""
st.markdown(hide_dataframe_row_index, unsafe_allow_html=True)
st.dataframe(df)
thx.
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.
thank you!
What if I want to use st.dataframe and not show the blank column? @sebastiandres @jeisma
+1. Traced exactly the steps above in the thread and wound up at the same (unsatisfactory) place.
df = pd.read_csv('notes_and_reports/31_Days/available_days.csv', header='infer', index_col=None)
# show df without index
df = df.fillna('')
# CSS to inject contained in a string
hide_dataframe_row_index = """
<style>
.row_heading.level0 {display:none}
.blank {display:none}
</style>
"""
# Inject CSS with Markdown
st.markdown(hide_dataframe_row_index, unsafe_allow_html=True)
st.dataframe(df)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.