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

Style not able to take formatters #11692

Closed
schwallie2 opened this issue Nov 24, 2015 · 4 comments
Closed

Style not able to take formatters #11692

schwallie2 opened this issue Nov 24, 2015 · 4 comments
Labels
API Design IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@schwallie2
Copy link

When using the new CSS styling, there doesn't seem to be a way to add formatters for the numbers. So trying to make the number data display as $10,000 when using any styling options currently seems off the table.
Documented here:
http://stackoverflow.com/questions/33875937/apply-number-formatting-to-pandas-html-css-styling

Related to this PR: #11667

@mattilyra
Copy link

I suppose the formatting should be expanded to cover all the functions in Styler not just .set_precision, so the following should take some kind of format={} kwarg that defines the format per column.

  • .highlight_min
  • .highlight_max
  • .highlight_max
  • .bar

This is partly implemented in #11667.

@TomAugspurger
Copy link
Contributor

API wise it'd be best to have a dedicated method for this, something like .format that takes a list of dictionaries mapping column to a python string formatting spec.

@schwallie2
Copy link
Author

Agree with the .format being better than implementing this everywhere. Can
we reuse formatters from to_HTML?
On Nov 25, 2015 7:15 AM, "Tom Augspurger" [email protected] wrote:

API wise it'd be best to have a dedicated method for this, something like
.format that takes a list of dictionaries mapping column to a python
string formatting spec.


Reply to this email directly or view it on GitHub
#11692 (comment).

This e-mail is only intended for the person(s) to whom it is addressed and
may contain confidential information. Any unauthorized review, use,
disclosure, or distribution is prohibited. If you received this e-mail in
error, please notify the sender by reply e-mail and then delete this
message and any attachments from your system. Thank you for your
cooperation.

@TomAugspurger
Copy link
Contributor

Can we reuse formatters from to_HTML?

Yeah we should match that API if possible.

I think our best bet implementation is to build up a more complicated dictionary outside of the template that contains another field with the formatted / to be displayed value. We'll look for that field in the template.

@jreback jreback added Output-Formatting __repr__ of pandas objects, to_string API Design IO HTML read_html, to_html, Styler.apply, Styler.applymap labels Nov 25, 2015
@jreback jreback added this to the 0.18.0 milestone Jan 28, 2016
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Feb 7, 2016
Closes pandas-dev#11692
Closes pandas-dev#12134
Closes pandas-dev#12125

This adds a `.format` method to Styler for formatting the display value
(the actual text) of each scalar value.

In the processes of cleaning up the template, I close pandas-dev#12134 (spurious 0)
and pandas-dev#12125 (KeyError from using iloc improperly)

cherry pick test from pandas-dev#12126

only allow str formatting for now

fix tests for new spec

formatter callable

update notebook
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Feb 12, 2016
Closes pandas-dev#11692
Closes pandas-dev#12134
Closes pandas-dev#12125

This adds a `.format` method to Styler for formatting the display value
(the actual text) of each scalar value.

In the processes of cleaning up the template, I close pandas-dev#12134 (spurious 0)
and pandas-dev#12125 (KeyError from using iloc improperly)

cherry pick test from pandas-dev#12126

only allow str formatting for now

fix tests for new spec

formatter callable

update notebook
HHammond pushed a commit to HHammond/pandas that referenced this issue Feb 13, 2016
Closes pandas-dev#11692
Closes pandas-dev#12134
Closes pandas-dev#12125

This adds a `.format` method to Styler for formatting the display value
(the actual text) of each scalar value.

In the processes of cleaning up the template, I close pandas-dev#12134 (spurious 0)
and pandas-dev#12125 (KeyError from using iloc improperly)

cherry pick test from pandas-dev#12126

only allow str formatting for now

fix tests for new spec

formatter callable

update notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants