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

Nanoplots compact formatting gets applied before removing exponent, causing error #334

Closed
machow opened this issue May 10, 2024 · 2 comments

Comments

@machow
Copy link
Collaborator

machow commented May 10, 2024

import polars as pl
from great_tables import GT

df = pl.DataFrame({"x": [[1, 2], [7045, 3]]})
GT(df).fmt_nanoplot("x", plot_type="bar")

raises this error:

image

This is because 7045 is converted to '7.04K', and then _remove_exponent() is trying to convert that to a decimal.

@machow
Copy link
Collaborator Author

machow commented May 10, 2024

Similarly this fails:

import polars as pl
from great_tables import GT

df = pl.DataFrame({"x": [[1, 2], [-704, 3]]})
GT(df).fmt_nanoplot("x", plot_type="bar")

~Because -704 has its minus sign converted (in the line above) from a hyphen (computer speak for minus) to the minus sign character. ~

edit: wait, it's because it's formatted to '-,704'

here's a minimal reprex:

from great_tables.vals import fmt_number

fmt_number(-704, n_sigfig=3, decimals=1, compact=True) # ['-,704']

@rich-iannone
Copy link
Member

Fixed by #335.

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

No branches or pull requests

2 participants