You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
coltype autodetection assumes "0.0" is a float and the table shows "0", instead of the string "0.0" #299
I couldn't find a way to enforce a column type to solve this issue:
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
>>> t = [["First version", "0.0"], ["Second version", "1.0"], ["Third version", "1.1"]]
>>> print(tabulate(t))
-------------- ---
First version 0
Second version 1
Third version 1.1
-------------- ---
I understand that it is not common to represent 0.0 as string, but I have the unusual requirement to printout versions and the auto-recognition of the column type cuts the ".0". Is there a way to enforce tabulate to keep it as string?
Setting disable_numparse to True will give you the result you are looking for:
>>> t = [["First version", "0.0"], ["Second version", "1.0"], ["Third version", "1.1"]]
>>> print(tabulate(t, disable_numparse=True))
-------------- ---
First version 0.0
Second version 1.0
Third version 1.1
-------------- ---
Activity
coltonpaquette commentedon Nov 24, 2023
Setting disable_numparse to True will give you the result you are looking for: