Skip to content

ENH: add decimal and thousands args to Styler.format() #40596

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 23 commits into from
Apr 20, 2021

Conversation

attack68
Copy link
Contributor

A PR for Europeans:

Screen Shot 2021-03-23 at 21 40 19

@jreback jreback added the Styler conditional formatting using DataFrame.style label Mar 23, 2021
@jreback jreback added this to the 1.3 milestone Mar 23, 2021
is a (float, complex).
"""

def wrapper(x):
Copy link
Contributor

Choose a reason for hiding this comment

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

can we share code with FloatArrayFormatter in pandas/io/format.py ?

may need to refactor to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

taking a quick look:

  • there doesn't seem to be an inherent option for thousands, just decimal replacement in that code.
  • the FloatArrayFormatter is vectorised but Styler does display_funcs element-wise (which it can't avoid for processing individual cell styles). I guess this makes it very difficult to refactor across module (unless the fomat_class was called element-wise)
  • other parameters such as escape and subset would have to be wrapped around the format.py code, so it might end up equally complicated anyway?

will have a think over next day.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jreback I think the refactor is too complicated at this stage since:

  • FloatArrayFormatter doesnt have the thousands argument which is main part of this PR.
  • the above problem about column vectorisation versus element-wise (and the styler subset argument)
  • the other arguments finding it difficult to exactly replicate existing behaviour.

@jreback jreback merged commit aab8799 into pandas-dev:master Apr 20, 2021
@jreback
Copy link
Contributor

jreback commented Apr 20, 2021

thanks @attack68
can you open an issue (and a PR if you can!) to try to unify the string formatting for these (and strings) at some point. thanks!

@attack68 attack68 deleted the format_decimal_thousands branch April 21, 2021 06:09
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request Apr 21, 2021
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants