-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add style to sheet-row from_dataframe() #190
Comments
An alternative, would maybe be a .from_dataframe_styler(), method that would except a pandas styler object. With a companion .to_dataframe_styler() ?
s is here a "styler"-object, not a pure dataframe any longer. And produces this error when being passed to .from_dataframe():
|
Hello @aecorn, My approach is to create the sheet from the dataframe, then pass the column with the checkboxes a renderer which at least colors the cell with the checkbox either green or red according to the value of the checkbox. The renderer is created as shown below:
After that, i am creating the sheet and apply the renderer to the column with the checkboxes like this:
However, the renderer seems to override the checkboxes. When initially all checkboxes are "False", each cell is colored red (which is okay so far), but there is no checkbox anymore. Instead there is a string saying "false" in each cell of this column and the column is on read_only mode because i cannot modify it in the sheet, while every other column is modifiable. (This is the reason why i tried to assign a read_only property to False in the renderer, which unfortunately did not render any change) Does anyone have an idea how to solve this problem and maybe even color the whole row depending on a checkbox being ticked - as @aecorn already suggested? |
Our use-cases will always be passing a pandas dataframe to a sheet, edit, then pass back to a dataframe, which I want to df.compare() with itself prior to editing, to log changes.
At the same time Id like to apply static styling to the rows, but the .from_dataframe() method seems to create sheets organized by columns, which is good I guess, as the typing of the columns (like checkboxing on bools), is a nice touch. So what Im after I guess is a method of applying styling to a row, dependant on one of the values in the row, on a sheet created from a dataframe, based on columns.
Code currently used below, commented out lines creates a sheet organized by rows instead, but misses the nice column-typing from from_dataframe().
df is a pandas dataframe, which has a column "Expired", which if True, should color the row blue.
Currently calling sheet[0, 0].style['backgroundColor'] = 'blue' on a sheet .from_dataframe() results in this error:
The text was updated successfully, but these errors were encountered: