Skip to content

Float format syntax #2502

Closed
Closed
@jorgsk

Description

@jorgsk

In for exampe DataFrame.to_csv there is the option "float_format" with the following description:

float_format : string, default None

Format string for floating point numbers

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions