-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: simplify Styler._translate
#43686
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
CLN: simplify Styler._translate
#43686
Conversation
@jreback got this to green. would appreciate pushing it through as a dependency to other prs. |
pandas/io/formats/style.py
Outdated
axis: int = 0, | ||
overwrite: bool = True, | ||
css: dict[str, str] | None = None, |
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.
oh i was thinking of leaving this and having you also add set_css
(cell_ids maybe not so important no?)
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.
'css' was a bad public name and too general so renamed.
there is a reason for including here. the class names do operate tablewide and set_table_styles
relies on certain classes, so:
styler.set_table_styles.set_css
wouldnt work while
styler.set_css.set_table_styles
would.
including here reduces dependencies.
pandas/io/formats/style.py
Outdated
@@ -141,12 +141,19 @@ class Styler(StylerRenderer): | |||
Object to define how values are displayed. See ``Styler.format``. If not given | |||
uses ``pandas.options.styler.format.formatter``. | |||
|
|||
.. versionadded:: 1.4.0 |
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.
since you are adding this to set_table_styles, do we need to add here (not a big deal but we already have a lot of options)
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.
for preference I prefer to. most dont import Styler
class but those who do might use it, and there are unlikely to be many more options added here in futures so this may be the last...
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.
i am confused over how this interacts with table_styles. can you either remove this enitrely or clarify.
@jreback ping green |
…classes # Conflicts: # doc/source/user_guide/style.ipynb
@jreback can I bump this up. Other PRs depend on it. Will change if you have strong opinion. |
pandas/io/formats/style.py
Outdated
axis: int = 0, | ||
overwrite: bool = True, | ||
css_class_names: dict[str, str] | None = None, | ||
cell_ids: bool | None = None, |
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.
do we need cell_ids here?
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.
removed/
pandas/io/formats/style.py
Outdated
@@ -141,12 +141,19 @@ class Styler(StylerRenderer): | |||
Object to define how values are displayed. See ``Styler.format``. If not given | |||
uses ``pandas.options.styler.format.formatter``. | |||
|
|||
.. versionadded:: 1.4.0 |
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.
i am confused over how this interacts with table_styles. can you either remove this enitrely or clarify.
ping @jreback. removed both and tested green. just noticed a doc update was also needed now. |
@@ -2000,6 +2016,22 @@ def set_table_styles( | |||
Styler.set_table_attributes: Set the table attributes added to the ``<table>`` | |||
HTML element. | |||
|
|||
Notes | |||
----- | |||
The default CSS classes dict, whose values can be replaced is as follows: |
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.
looks good. in a followup can you add how this interacts with table_styles, e.g. when to use each one (via docs / examples).
thanks @attack68 |
very nice, just a comment for followup. |
Bit of a pre cursor to some other cleaning in #43649.
Prevents needing to pass variables around in worker functions, and has the added benefit of making the CSS classes user editable, by storing as a class attribute instead of module constants.
I ran the updated styler ASVs for this and "BENCHMARKS NOT SIGNIFICANTLY CHANGED"