-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Conditionally styling by HTML classes #14226
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
Comments
I think this would be a fantastic addition. I think either the |
This should be terribly difficult to add, if anyone is interested in implementing it. I'd prefer the |
I agree with the above and think it would be very useful in general. I use styling quite extensibly to add formatting logic to user-dynamic tables, and that aspect works well, but it requires some quite extensive coding to get it working efficiently for large tables. On thing that would be handy is a set_column_styles() method. I currently have this workaround
I don't really have the ability yet to try and integrate this and do the github push, but it would be great if the above could be redefined as:
|
This comment has been minimized.
This comment has been minimized.
this is closed by PR #36159 |
Currently the
DataFrame.Styler
class provides for adding of css key/value attribute pairs. But it is sometimes preferable to add a HTML class to a cell instead, and then let the styling be done by an external css file.As an example consider the following DataFrame:
As an example, we would like to attach the class "negative" to the -5 and receive the following HTML:
Regarding how to implement this, here are a couple of ideas:
by_class
toapply()
andapplymap()
that instructs the styler that the "function" will return a classes instead of css strings.isinstance(ret,StyleClass)
to determine whether to modify the style directly or by adding additional classes.IMO, I believe that it would be a better interface of styler that apply and applymap were to return classes by default and then optionally provide a css style sheet that can be resolved when turning the style into html. Such an approach would also be easier to adapt to additional backends, e.g. LaTeX. The disadvantage though is that it would break backwards compatibility, and that it would make styling for iPython (the main usecase?) more complicated.
The text was updated successfully, but these errors were encountered: