I noticed a problem on the dataframe widget regarding the width of the columns
If the length of the dataframe is < 5 the headers are displayed in full
the most surprising is that if we first display a dataframe with a length < 5 and update the display, we keep the names of the columns in full
Is it due to the recent update?
Is there a way around the problem without using table or aggrid or plotly table?
Below is the code to reproduce this problem
import pandas as pd
import streamlit as st
L = list(range(100))
d = {'AAAAAAA': L,
'BBBBBBB': L,
'CCCCCCC': L,
}
df = pd.DataFrame(d)
c1,c2 = st.columns(2)
c1.dataframe(df[:5])
if not c2.button("Increase len"):
c2.dataframe(df[:4])
else :
c2.dataframe(df)
Thanks for reporting this issue. The technical reason for the difference is that there is an outlier detection built into the automatic sizing algorithms that kicks in at > 5 rows. The column size is calculated by taking the maximum width of the largest cell, but outliers (with a lot larger width than all other cells) are ignored. That’s why the header is ignored here. But there are some improvements we could implement for the automatic sizing algorithms. We might also add an option to configure the width of a column manually as well.
The old st._legacy_dataframe or st.table might be a temporary alternative here as well.
Thanks for the advice st._legacy_dataframe do the job perfectly
i’m afraid that the new dataframe system is so … useless
streamlit is a great tool but industry have a high requirement for table formatting
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
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.
Performance cookies
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.
Functional cookies
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.
Targeting cookies
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.