Open buhtz opened 1 year ago
thanks @buhtz for the report
could you report to tabulate
please?
In [5]: df = pandas.DataFrame([[pandas.NA]])
In [6]: tabulate.tabulate(df)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 tabulate.tabulate(df)
File ~/pandas-dev/.311venv/lib/python3.11/site-packages/tabulate/__init__.py:2048, in tabulate(tabular_data, headers, tablefmt, floatfmt, intfmt, numalign, stralign, missingval, showindex, disable_numparse, colalign, maxcolwidths, rowalign, maxheadercolwidths)
2045 if tabular_data is None:
2046 tabular_data = []
-> 2048 list_of_lists, headers = _normalize_tabular_data(
2049 tabular_data, headers, showindex=showindex
2050 )
2051 list_of_lists, separating_lines = _remove_separating_lines(list_of_lists)
2053 if maxcolwidths is not None:
File ~/pandas-dev/.311venv/lib/python3.11/site-packages/tabulate/__init__.py:1471, in _normalize_tabular_data(tabular_data, headers, showindex)
1469 headers = list(map(str, headers))
1470 # rows = list(map(list, rows))
-> 1471 rows = list(map(lambda r: r if _is_separating_line(r) else list(r), rows))
1473 # add or remove an index column
1474 showindex_is_a_str = type(showindex) in [str, bytes]
File ~/pandas-dev/.311venv/lib/python3.11/site-packages/tabulate/__init__.py:1471, in _normalize_tabular_data.<locals>.<lambda>(r)
1469 headers = list(map(str, headers))
1470 # rows = list(map(list, rows))
-> 1471 rows = list(map(lambda r: r if _is_separating_line(r) else list(r), rows))
1473 # add or remove an index column
1474 showindex_is_a_str = type(showindex) in [str, bytes]
File ~/pandas-dev/.311venv/lib/python3.11/site-packages/tabulate/__init__.py:107, in _is_separating_line(row)
104 def _is_separating_line(row):
105 row_type = type(row)
106 is_sl = (row_type == list or row_type == str) and (
--> 107 (len(row) >= 1 and row[0] == SEPARATING_LINE)
108 or (len(row) >= 2 and row[1] == SEPARATING_LINE)
109 )
110 return is_sl
File ~/pandas-dev/pandas/_libs/missing.pyx:413, in pandas._libs.missing.NAType.__bool__()
411
412 def __bool__(self):
--> 413 raise TypeError("boolean value of NA is ambiguous")
414
415 def __hash__(self):
TypeError: boolean value of NA is ambiguous
OK, thanks.
I'm not sure about your Issue policy. IMHO this can be closed because it is not pandas related.
We'll probably want to set a minimum version of tabulate when it's fixed, so let's keep it open til then. Thanks!
There is an open PR at "tabulate". https://github.com/astanin/python-tabulate/pull/232
Tabulate seems unmaintained, see https://github.com/astanin/python-tabulate/issues/281
I had a similar bug on linux.
In case this is useful, I managed to get around the bug by inserting a .astype(str)
before the .to_markdown()
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
It seems that the markdown output has a problem with the
<NA>
. But his only happens on Windows with pandas 1.5.3 not on Debian 11 (stable, raspberryPi) with pandas 1.5.3.Expected Behavior
No exception.
Installed Versions
Sorry, I wasn't able to install
main
because building takes to long on a Pi4. ;) On my Windows I'm not able to install anything from git because I'm not the admin.This is the Windows info where the error happens.
This is the GNU/Linux Debian 11 info where the error is not reproducable.