widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.62k stars 105 forks source link

[Feature Request] solara DataFrame should handle pandas Styler #110

Open chaffra opened 12 months ago

chaffra commented 12 months ago

If you have a styled df = pandas.DataFrame().style, you can pass it as sdf = solara.DataFrame(df.data) but you loose the styling that was applied to df. So if columns were hidden by the styler, they are displayed again. It would be good for solara.DataFrame to reapply the style before when displaying sdf in a notebook for example.

maartenbreddels commented 11 months ago

Hi,

i'm not sure we should support the .style attribute in our DataFrame component, but maybe https://solara.dev/api/display is what you want display(df) in a component should get you the same output as in the notebook. Is that want you need?

alonsosilvaallende commented 6 months ago

I don't know which feature from pandas Styler @chaffra wants, but in my case I would like to remove the index column or alternatively to set as index another column (in the example below the column "token ID"). Any idea on how to do that?

Screenshot 2023-10-27 101757
GijsVermarien commented 2 weeks ago

@alonsosilvaallende I was looking into getting a sensible first column as well. The first step I used was to set the token ID as index in pandas df = df.set_index("Token ID"). Then the default display method of pandas will already use this column as an index instead. Solara dataframes don't support this view yet, but I saw that someone has created a pull request to support it here: #526