-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Display Cell Colors in a Dataframe #2688
Comments
Need to work on this soon as more people have asked about it (@sashavor) |
I don't think this is the right approach because it won't work with themes. Does pandas have a way of semantically labelling cells? Stuff like the formatting of contents is fine but not things like colors. I understand the need to 'highlight' certain fields or rows/ cols but i think it should be framed in that way. If we need our own API for this then I think that is okay too, if it is possible. |
The use case I've seen for this is creating heatmaps for your data. This is how the pandas syntax works right now, you basically pass a This is the pandas syntax: import pandas as pd
import numpy as np
rs = np.random.RandomState(0)
df = pd.DataFrame(rs.rand(10, 10))
corr = df.corr()
corr.style.background_gradient(cmap='coolwarm') Are you suggesting the color map be included in the theme in the theme api? |
That is a very good question. It would certainly be cool if 'official' themes actually supported a set of visualisation palettes. Which has now reminded me of that issue that I forgot about: #2780 |
Just got another request for this here: https://discord.com/channels/879548962464493619/1139122387921666048 |
+1 on this. Would be very helpful to have this! |
@sedrick-keh-tri we're working on implementing this -- would be very helpful if you can share what your use case is for adding color to cells, specifically how you intend the colors to be specified. Are you coloring based on the data in each cell for example? Or are you specifying the color of each cell yourself? |
More of the latter. I have a table and I would like to highlight certain rows for emphasis |
And is it a dataframe that you're planning on editing interactively afterwards or just statically to display content? |
Statically display content |
+1 Would be very helpful to have this. Any ETA on this feature? |
We have an open PR but it still needs a bit of work. Please follow #5569 to keep up to date. |
Is your feature request related to a problem? Please describe.
In pandas, you can use the style property to apply formatting to your data (cell background colors, rounding decimals) and then get an HTML representation of the table.
Gradio developers can display this data with the HTML component but at that point you loose the ability to add/remove/edit cells and sort by cell contents.
It would be better if the dataframe component could take in the style defined on the backend.
Describe the solution you'd like
The gr.DataFrame component takes the output of the pandas.style method.
Open to other suggestions for how to support the colored cell case.
Additional context
Came up during the Data Measurements project (huggingface/data-measurements-tool#45)
The text was updated successfully, but these errors were encountered: