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 #40032 and PR #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 Mar 1, 2021
@jreback jreback added the Styler label Mar 2, 2021
@TomAugspurger
Copy link
Contributor

@TomAugspurger TomAugspurger commented Mar 3, 2021

The idea seems good to me. Looks like we'll need a release note.

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
@attack68 attack68 requested a review from jreback Mar 3, 2021
@jreback jreback added this to the 1.3 milestone Mar 4, 2021
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 Mar 4, 2021
Copy link
Contributor

@jreback jreback left a comment

small comment, ping on greenish

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

@jorisvandenbossche jorisvandenbossche left a comment

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 Mar 5, 2021
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 attack68 commented Mar 5, 2021

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

jreback
jreback approved these changes Mar 5, 2021
@jreback jreback merged commit 154026c into pandas-dev:master Mar 5, 2021
22 checks passed
@jreback
Copy link
Contributor

@jreback jreback commented Mar 5, 2021

thanks @attack68 very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants