Skip to content

floatfmt doesn't work when tablefmt="pretty" #71

Open

Description

@TalAmuyal

Reproduced with tabulate==0.8.7

import tabulate


table = tabulate.tabulate(
    [
        [1.10000001],
    ],
    tablefmt="pretty",
    floatfmt=".3f",
)

print(table)

yields

+------------+
| 1.10000001 |
+------------+

instead of

+-------+
| 1.100 |
+-------+

Activity

  1. jhutar commented on Nov 5, 2020

    @jhutar

    I can see this too - also I have tabulate==0.8.7 on Python 3.9.0.

  2. flcong commented on Jan 27, 2021

    @flcong

    I find the same issue with tabulate==0.8.7 on Python 3.8.5

  3. astanin commented on Feb 17, 2021

    @astanin
    Owner

    PrettyTable formatter was added in ba3c203, and it doesn't parse/reformat numbers.
    This is by design, but this particular design choice leaves much to be desired.

    I assume that at this point some users may depend on the format behaving like this.
    But the formatter may see some not-backwards-compatible improvement in the next major version.

    So the next version of the "pretty" format should change existing output tests as little as possible by default,
    but it should also respect floatfmt, if given.

  4. added this to the v0.9 milestone on Feb 17, 2021
  5. modified the milestones: v0.9, v0.9.1 on Oct 19, 2022
  6. removed this from the v0.9.1 milestone on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions