-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Different precision calling .astype(str) on float numbers #11302
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
Comments
what version of numpy? |
numpy 1.10.0 |
in both cases? |
in both cases yes. I updated with conda update pandas, which also updated numpy. Then I downgraded pandas with conda install pandas=0.16.2 and it worked again. |
this might be just a printing thing eg the display.precision changed in 0.17.0 |
0.16.2:
0.17:
|
no see if the actual numbers are th same eg df.at[0,0] |
0.16.2:
0.17:
|
0.16.2
0.17.0
This is python 2.7 on macosx. pls be more specific about python/os |
do you get the same when using .to_dict()? Also I used the python console instead of ipython/notebook to make sure it's not a display issue cause by ipython. I'm running Python 3.4.3 :: Anaconda 2.3.0 (x86_64) on macosx. |
(numpy 1.10.1 just released, but doesn't have anything to do with this) |
so this is just on py3 looks like. |
so this goes thru a slightly different path that in 0.16.2 but not really sure why this would have changed. I'll mark it as a bug, though odd that you actually rely on this behavior? |
thank you. I'm not sure about the "output-formatting" label though, isn't this more of a type-conversion/casting issue (float to str)? I rely on astype(str) for two things:
So I'll try now to find a way to make it through the unittests with 0.17 since I'd like to update due to the new features/optimizations. If you have an idea for a quick workaround let me know... |
Regarding a workaround, this helps me for now to get through the unit-tests: df.applymap(lambda x: str(x)).to_dict() instead of df.astype(str).to_dict() Another difference I noticed is when np.NaN is converted to strings:
To be honest I wonder if it wouldn't be a good idea to get the same results with astype(str) as with the standard python str() function? For me there's a significant difference between an empty string and np.NaN. |
@marcomayer ok, should be fixed in #11309 a better way to compare things is just to use |
that fixed it for me! thanks a lot! I'll also consider np.allclose() for the future. Marco |
REGR: change in output formatting for long floats/nan, #11302
With pandas 0.16.2:
With pandas 0.17:
I read the 0.17 release log but couldn't figure out why that is. Is it a bug or a new feature, and if it's a new feature how can I re-activate the old behavior?
The text was updated successfully, but these errors were encountered: