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

BUG: Styler format na_rep arg overwrites existing when not given. #40032

Closed
attack68 opened this issue Feb 24, 2021 · 0 comments
Closed

BUG: Styler format na_rep arg overwrites existing when not given. #40032

attack68 opened this issue Feb 24, 2021 · 0 comments
Labels
Bug Styler conditional formatting using DataFrame.style
Milestone

Comments

@attack68
Copy link
Contributor

Styler has its own format() method that sets a formatter for columns, and a function set_na_rep() for dealing with missing data.
It seems the two do not play well together:

df = pd.DataFrame([[1,2],[3,4]])
df.iloc[0,0] = np.nan
df.style.set_na_rep('MISS').set_precision(1)

MISS | 2
3.0 | 4

df.style.set_na_rep('MISS').format('{:,.1f}')

nan | 2.0
3.0 | 4.0

df.style.set_na_rep('MISS').format('{:,.1f}', na_rep='PASS')

PASS | 2.0
3.0 | 4.0

could probably do with a review how the attribute na_rep interacts with the formatter and try to make it more dynamic or use pointers instead of static value, if possible.

@attack68 attack68 added Bug Needs Triage Issue that has not been reviewed by a pandas team member Styler conditional formatting using DataFrame.style and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 24, 2021
@jreback jreback added this to the 1.3 milestone Mar 5, 2021
@attack68 attack68 closed this as completed Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants