Is there a way to define the format style (number of decimals) for the Python module tabulate
?
For example:
I have the number 3.34643745.
I want to format the number of decimals to print out only two decimal places.
Output: 3.34
Is there a way to define the format style (number of decimals) for the Python module tabulate
?
For example:
I have the number 3.34643745.
I want to format the number of decimals to print out only two decimal places.
Output: 3.34
Yes you can do something like:
print tabulate([["pi",3.141593],["e",2.718282]], floatfmt=".2f")
Which will print:
-- ----
pi 3.14
e 2.71
-- ----