BUG: DataFrame.to_markdown exception when a cell has numpy.array type #61337
Labels
Bug
Dependencies
Required and optional dependencies
IO Data
IO issues that don't fit into a more specific label
Needs Discussion
Requires discussion from core team before further action
Nested Data
Data where the values are collections (lists, sets, dicts, objects, etc.).
Uh oh!
There was an error while loading. Please reload this page.
Pandas version checks
I have checked that this issue has not already been reported.
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
When a dataframe contains a cell with type numpy.array, the to_markdown function will fail. The exact issue is due to differing behavior between any other value and numpy arrays, but the reason I think this is a pandas issue is because an assumption is made about the value:
Anything that isn't a string will normally result in this comparison resolving to
False
, but this should be explicit to avoid strange datatypes causing undefined behavior.Stack trace:
Expected Behavior
to_markdown converts this numpy array to string and outputting a markdown normally. Instead there's an exception
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.13.1
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.26100
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.2.3
numpy : 2.2.4
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.0.1
Cython : None
sphinx : None
IPython : 9.0.2
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 19.0.1
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: