Bug: implicit conversion of strings to exponent. (tabulate converting types)
See original GitHub issueThis is a bug is converting strings like this 20200407_2 to exponent values.
>>> print(tabulate.tabulate([ [93, '20200310.2'], [65, '20200407_2'] ]))
-- -----------
93 2.02003e+07
65 2.02004e+08
-- -----------
surprising that float will convert this one at all as it has an underscore in it.
>>> float('20200407_2')
202004072.0
Anyway tabulate should not be converting types at all.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why does implicit conversion from some numeric values work ...
It tries to convert your string to a numeric(3,2) because that's the type on the right of the multiplication 1. If you can...
Read more >Passing a String Where It Isn't Expected:Exploring the Implicit ...
Looking at a method signature reveals the expected argument types but not what types can be implicitly converted to those expected types.
Read more >Avoid Implicit Data Conversion in WHERE Clause
A VARCHAR2 or CHAR value can be implicitly converted to NUMBER or DATE type value by Oracle. Similarly, a NUMBER or DATA type...
Read more >Implicit and Explicit Conversions - Visual Basic - Microsoft Learn
The following table shows the available conversion keywords. Type conversion keyword, Converts an expression to data type, Allowable data types ...
Read more >Conversion rules | BigQuery - Google Cloud
Literal conversion is evaluated at analysis time, and gives an error if the input literal cannot be converted successfully to the target type....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pete312 I was able to fix the issue by invoking the disable_numparse argument:
print(tabulate.tabulate([ [93, '20200310.2'], [65, '20200407_2'] ], disable_numparse=True))
@astanin The end point of tabulate is text align and is display only. Auto convert int to str is fine but going back is not consistent in regression. Meaning tabulate will output different results python 3.6 than prior versions of python 3. because python 3.6 allows an int to be defined as 20200407_2 and not before 3.6. However “20200407_2” and 20200407_2 are not equal. Also the output of print(20200407_2) is not the same as string “20200407_2”.
To me this means tabulate is incorrectly converting a previously string type to an int type. Output will differ after 3.6 with this default set to True. It will not break if set to False. Usually regression test failure are considered as bugs. “Undefined behavior” or “Inconsistant Feature”