Skip to content
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

DEPR: Styler.set_na_rep and .set_precision in favour of .format(na_rep='x', precision=3) #40134

Merged
merged 43 commits into from Mar 5, 2021

Conversation

attack68
Copy link
Contributor

@attack68 attack68 commented Mar 1, 2021

  • closes issue BUG: Styler format na_rep arg overwrites existing when not given. #40032 and PR BUG/ENH: Styler.format() always inherits from .set_na_rep() #40060
  • deprecates the methods Styler.set_na_rep() and Styler.set_precision() in favour of, and incorporating precision into Styler.format(). Maintains some backwards compatibility with a deprecation warning, the copy mechanics remain broken.
    • Styler.set_na_rep('MISS') is replaced and equivalent to Styler.format(na_rep='MISS')
    • Styler.set_precision(5) is replaced and equivalent to Styler.format(precision=5)
    • Styler.set_na_rep('MISS').set_precision(5) is equivalent to Styler.format(na_rep='MISS', precision=5)
    • Styler.set_precision(5).set_na_rep('MISS') is equivalent to Styler.format(na_rep='MISS', precision=5)
  • moves the default_formatter and maybe_wrap_formatter methods to module level.
  • documentation is added to show new functionality
  • most existing tests still pass with, some needed minor modification and some were no longer necessary
  • tests added for new combinations
  • whatsnew entry

This PR was suggested after review of #40060 as an alternative. It seems to be a simpler and more consistent solution for API.

@attack68 attack68 marked this pull request as draft March 1, 2021 09:03
pandas/io/formats/style.py Show resolved Hide resolved
pandas/io/formats/style.py Outdated Show resolved Hide resolved
pandas/tests/io/formats/style/test_style.py Show resolved Hide resolved
pandas/io/formats/style.py Outdated Show resolved Hide resolved
pandas/tests/io/formats/style/test_style.py Outdated Show resolved Hide resolved
pandas/io/formats/style.py Outdated Show resolved Hide resolved
@attack68 attack68 requested a review from jreback March 4, 2021 09:19
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small comment, ping on greenish

pandas/io/formats/style.py Outdated Show resolved Hide resolved
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Didn't review the code, but conceptually looks good! And a few doc comments

doc/source/whatsnew/v1.3.0.rst Outdated Show resolved Hide resolved
pandas/io/formats/style.py Outdated Show resolved Hide resolved
pandas/io/formats/style.py Outdated Show resolved Hide resolved
attack68 and others added 4 commits March 5, 2021 17:50
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@attack68
Copy link
Contributor Author

attack68 commented Mar 5, 2021

@jreback ping this is greenish, if you approve the changes to the docstring formatterabove

@jreback jreback merged commit 154026c into pandas-dev:master Mar 5, 2021
@jreback
Copy link
Contributor

jreback commented Mar 5, 2021

thanks @attack68 very nice!

@jbrockmendel
Copy link
Member

@attack68 want to make a PR enforcing this deprecation?

@attack68
Copy link
Contributor Author

yes will do. been waiting for the 2.0 tag to push to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants