Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting dataframe width doesn't have effect #4931

Closed
alexscott-ff opened this issue Jul 5, 2022 · 7 comments · Fixed by #5221
Closed

Setting dataframe width doesn't have effect #4931

alexscott-ff opened this issue Jul 5, 2022 · 7 comments · Fixed by #5221

Comments

@alexscott-ff
Copy link

Summary

Providing st.dataframe a width doesn't seem to have the desired effect.

Steps to reproduce

Code snippet:

st.dataframe(df, width=1200)

Screen Shot 2022-07-04 at 9 42 00 PM

That's the output of the table, regardless of whether I give the width argument or not.

Expected behavior:

The table width is set to the integer number of pixels and the column widths are dispersed evenly within that width.

Actual behavior:

The table doesn't change size.

Is this a regression?

Don't think so.

Debug info

  • Streamlit version: 1.10
  • Python version: 3.9.13
  • OS version: OS X
  • Browser version: Chrome latest

Additional information

I believe this is due to the columns themselves not having width and just taking enough width to fit the values. But the header values (column names) seem to get ignored when making that calculation.

I tried to play around with the CSS but due to Canvas was unable to do things easily in inspection mode in the browser.

As an aside, would really like a full-width, responsive dataframe option (potentially as default).

@alexscott-ff alexscott-ff added type:bug Something isn't working status:needs-triage Has not been triaged by the Streamlit team labels Jul 5, 2022
@alexscott-ff alexscott-ff changed the title Dataframe width doesn't have effect Setting dataframe width doesn't have effect Jul 5, 2022
@LukasMasuch LukasMasuch added feature:st.dataframe priority:P2 Champions 💖 and removed status:needs-triage Has not been triaged by the Streamlit team labels Jul 6, 2022
@LukasMasuch
Copy link
Collaborator

@alexscott-ff Thanks for reporting this issue.

I believe this is due to the columns themselves not having a width and just taking enough width to fit the values.

That's indeed the reason why it currently fails to set the width. Unfortunately, there is no good workaround at the moment to fix this with st.dataframe. We will soon investigate some time to improve the automatic column sizing, which I assume will also fix this issue.

@alexscott-ff
Copy link
Author

Sounds good, thanks for the quick response @LukasMasuch !

@TheRealJoci
Copy link

Has there been any updates on this? This makes Dataframes unusable right?

@gigantic65
Copy link

Has there been any updates on this? I had same problems.

@katiaviene
Copy link

any updates? this df behavior makes my eye tick!

@astrowonk
Copy link

I have the same issue. I can use st.table which looks fine but of course I lose the interactivity.

I think if it could just take the header width into account when sizing the columns that might help, though I'd still eventually want the width parameter to have an effect.

@scott-trinkle
Copy link

+1 for this, the current implementation is unusable, I have to use st._legacy_dataframe for all dataframes instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants