Skip to content

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

Merged
merged 41 commits into from
Oct 16, 2021

Conversation

attack68
Copy link
Contributor

@attack68 attack68 commented Sep 21, 2021

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"

@jreback jreback added the Styler conditional formatting using DataFrame.style label Sep 23, 2021
@jreback jreback added this to the 1.4 milestone Sep 23, 2021
@jreback jreback added the Refactor Internal refactoring of code label Sep 23, 2021
@attack68
Copy link
Contributor Author

@jreback got this to green. would appreciate pushing it through as a dependency to other prs.

axis: int = 0,
overwrite: bool = True,
css: dict[str, str] | None = None,
Copy link
Contributor

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?)

Copy link
Contributor Author

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.

@attack68 attack68 requested a review from jreback October 3, 2021 16:38
@@ -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
Copy link
Contributor

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)

Copy link
Contributor Author

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...

Copy link
Contributor

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.

@attack68
Copy link
Contributor Author

attack68 commented Oct 5, 2021

@jreback ping green

@attack68 attack68 requested a review from jreback October 8, 2021 08:09
@attack68
Copy link
Contributor Author

@jreback can I bump this up. Other PRs depend on it. Will change if you have strong opinion.

axis: int = 0,
overwrite: bool = True,
css_class_names: dict[str, str] | None = None,
cell_ids: bool | None = None,
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed/

@@ -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
Copy link
Contributor

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.

@attack68
Copy link
Contributor Author

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:
Copy link
Contributor

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).

@jreback jreback merged commit 445bb9f into pandas-dev:master Oct 16, 2021
@jreback
Copy link
Contributor

jreback commented Oct 16, 2021

thanks @attack68

@jreback
Copy link
Contributor

jreback commented Oct 16, 2021

very nice, just a comment for followup.

@attack68 attack68 deleted the clean_styler_css_classes branch October 16, 2021 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants