-
Notifications
You must be signed in to change notification settings - Fork 4k
Allow markdown in st.table
#10088
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
Allow markdown in st.table
#10088
Conversation
|
|
| While ``st.dataframe`` is geared towards large datasets and interactive | ||
| data exploration, ``st.table`` is useful to display a small table without | ||
| scrolling – e.g. a confusion matrix or a leaderboard. For this reason, it also | ||
| supports Markdown formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfc-gh-dmatthews FYI I updated the description here to make it a bit easier to understand the differences.
| >>> st.table(df) | ||
| .. output:: | ||
| https://doc-table-markdown.streamlit.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfc-gh-dmatthews we still need to deploy an app here or integrate the code into the previous app. Also, feel free to change the code in any way you want!
e2e_playwright/__snapshots__/linux/st_table_test/st_table-10[firefox].png
Show resolved
Hide resolved
e2e_playwright/__snapshots__/linux/st_table_test/st_table-31[firefox].png
Show resolved
Hide resolved
|
@lukasmasuch I implemented all the comments above, can you give this another look and approve? |
| static: its entire contents are laid out directly on the page. | ||
| While ``st.dataframe`` is geared towards large datasets and interactive | ||
| data exploration, ``st.table`` is useful to display a small table without | ||
| scrolling – e.g. a confusion matrix or a leaderboard. For this reason, it also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we also add that st.table is geared towards more style-related customizability? E.g. it also supports a lot more Pandas Styler features compared to st.dataframe.
lukasmasuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 We just merged some other changes related to ArrowTable, it might need merging + recreating of the snapshots.
Also, it probably makes sense to add this to our new markdown_features e2e test as well (e.g. just use a dataframe with a single markdown cell).
## Describe your changes Adds markdown support in `st.table` for data cells, row index, and column headers. Note that unlike labels, this doesn't have any restrictions on which markdown features can be used. I think table cells are big enough to handle larger markdown elements (such as headers or bullet lists) without looking ugly. I also changed the empty value from `<NA>` to a non-breaking space (i.e. an empty cell) because the smaller/greater symbols caused problems with the markdown formatting. Note that for `st.dataframe` we use `None` for empty values. In `st.table`, I think an empty cell looks nicer though, because `st.table` is less geared towards exploring actual datasets where it might be important to see the actual values and more towards showing a small table of fixed values.  ## GitHub Issue Link (if applicable) Closes streamlit#8785 Should also leave a note on streamlit#6461, which asks for markdown on `st.dataframe`. ## Testing Plan - Added an e2e snapshot test for a table with various markdown features. - I also tried adding JS unit tests but it's not super easy because we need to add the encoded data for a Markdown table in `frontend/lib/src/mocks/arrow/index.ts`. Not sure if it's worth doing that given that the e2e test already covers everything. - Note that a lot of snapshots changed because of the move from `<NA>` to an empty cell. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: Johannes Rieke <[email protected]>
Describe your changes
Adds markdown support in
st.tablefor data cells, row index, and column headers. Note that unlike labels, this doesn't have any restrictions on which markdown features can be used. I think table cells are big enough to handle larger markdown elements (such as headers or bullet lists) without looking ugly.I also changed the empty value from
<NA>to a non-breaking space (i.e. an empty cell) because the smaller/greater symbols caused problems with the markdown formatting. Note that forst.dataframewe useNonefor empty values. Inst.table, I think an empty cell looks nicer though, becausest.tableis less geared towards exploring actual datasets where it might be important to see the actual values and more towards showing a small table of fixed values.GitHub Issue Link (if applicable)
Closes #8785
Should also leave a note on #6461, which asks for markdown on
st.dataframe.Testing Plan
frontend/lib/src/mocks/arrow/index.ts. Not sure if it's worth doing that given that the e2e test already covers everything.<NA>to an empty cell.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.