-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: format small floats correctly (GH9764) #9806
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
Conversation
Values from range [1e-7, 5e-7] (for display.precision=7) not displaying 0 anymore
This should have a test to verify that your fix works. We use unit tests to verify our public API, but they're also for internal usage. The test will guarantee that nobody breaks this behavior without thinking carefully about it, even if we're not going to guarantee the output format to our users. |
Sure, test added to branch. |
|
||
# In case default display precision changes: | ||
saved_option=pd.get_option('display.precision') | ||
pd.set_option('display.precision', 7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you set this with the context manager pd.option_context()
instead? That's safer than setting a global variable.
looks pretty good -- could you add a line to the bug fix section of the release notes for v0.16.1? |
also prob needs a test with mixed (meaning a really small number and a normal sized float). further this prob needs a quick way (eg vectorizes) to figure out whether to do this formatting (eg see how Timedelta does it for example) otherwise perf on a big array may be a problem |
@shoyer Thanks for comments - updated. I have also noticed that some of my commit msgs were not 100% in line with the contribution recommendations, so I've updated them. |
ok this lgtm |
BUG: format small floats correctly (GH9764)
Thanks @tomazberisa! |
closes #9764
In order to display a number from range (0,1) in decimal format with N significant digits (and not in scientific format), the number needs to be greater than or equal to 1e(-N+1), not 1e-N.
Did not test for range of display.precision, as this does not seem to current practice.
Did not include tests as they would imply an output format which might change in the future.