-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: could not convert string to float: 'True' #135
Comments
The basic assumption of tabulate is that values in the same column are of the same type. Though I agree that the exception should not be thrown. The minimal example to reproduce this error is this one: tabulate([[0.1], ['True']]) |
Duplicate of #209 ? |
While looking into this issue I found a similar bug: >>> tabulate([[1000], ['True']], intfmt=',')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 2176, in tabulate
cols = [
^
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 2177, in <listcomp>
[_format(v, ct, fl_fmt, int_fmt, miss_v, has_invisible) for v in c]
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 2177, in <listcomp>
[_format(v, ct, fl_fmt, int_fmt, miss_v, has_invisible) for v in c]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 1231, in _format
return format(val, intfmt)
^^^^^^^^^^^^^^^^^^^
ValueError: Cannot specify ',' with 's'. And another one: >>> tabulate([["1000"]], intfmt=',')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 2176, in tabulate
cols = [
^
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 2177, in <listcomp>
[_format(v, ct, fl_fmt, int_fmt, miss_v, has_invisible) for v in c]
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 2177, in <listcomp>
[_format(v, ct, fl_fmt, int_fmt, miss_v, has_invisible) for v in c]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ibo\Python\python-tabulate\tabulate\__init__.py", line 1231, in _format
return format(val, intfmt)
^^^^^^^^^^^^^^^^^^^
ValueError: Cannot specify ',' with 's'. |
All these bugs happen in _format(): python-tabulate/tabulate/__init__.py Lines 1213 to 1247 in 83fd4fb
...when
I'll have a go at fixing those. Interestingly, this is one of the core functions of the library. It existed as early as in the first commit a83993e of this repo, made more than 10 years ago, although it was much cuter at the time: Lines 26 to 32 in a83993e
|
version: 0.8.9, Python 3.6.9, reproduction code:
If I replace
str(v)
byv
:The text was updated successfully, but these errors were encountered: