-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Float format syntax #2502
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
Thinking out loud about how to fix this: This could be addressed with either:
The best fix would be to write a test for the new floating point format, and then an implementation for it. To find the corresponding code, namely the "to_csv" function, you can search with: git grep "def to_csv" showing a match in pandas/core/frame.py. The documentation is also right there, in the same file. |
This issue leads to other limitation: As it is, one cannot easily set a float_format string that could handle comma as thousands separator or currency strings (i.e., "${:,}" for "${:,}".format(122222) ). |
closing in favor of master issue #4668 |
In for exampe DataFrame.to_csv there is the option "float_format" with the following description:
The currently allowed format in Pandas follows the "old" Python style of '%.2f' % 1.234, so you have to write
float_format = '%.df'.
Being used to 2.7 and 3.x formatting style of Python, I expected that just ':.2f' or even '.2f' would be valid.
To keep up with the new formatting style, should these two last variants (or one of them) also be accepted in Pandas? If not, it should be specified in the documentation, perhaps with an example, that the '%'-style is required.
The text was updated successfully, but these errors were encountered: