jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.32k stars 149 forks source link

`float_format` not working #301

Closed watermelon0guy closed 2 months ago

watermelon0guy commented 2 months ago

What did you do?

Use float_format

What did you expect to happen?

It works

What actually happened?

It not work

What versions are you using?

import prettytable as pt

arr = [1.3310884083630156e-05, 6.655442041815078e-06, 5.546201701512565e-06]

table = pt.PrettyTable()
table.float_format = "0.8"

table.add_row(arr)

print(table)
+------------------------+-----------------------+-----------------------+
|        Field 1         |        Field 2        |        Field 3        |
+------------------------+-----------------------+-----------------------+
| 1.3310884083630156e-05 | 6.655442041815078e-06 | 5.546201701512565e-06 |
+------------------------+-----------------------+-----------------------+
hugovk commented 2 months ago

(Duplicate of https://github.com/jazzband/prettytable/issues/300)