BUG: ExtensionArrays whose elements are non-numeric numpy arrays crash Series.__repr__() #33770
Closed
3 tasks done
Labels
Bug
ExtensionArray
Extending pandas with custom dtypes or arrays.
Output-Formatting
__repr__ of pandas objects, to_string
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Prerequisites:
Reproduce the problem, using
TensorArray
, our extension type for storing tensors in a Pandas series:Problem description
Series.__repr__()
invokesExtensionArrayFormatter
to render extension types. If the individual elements managed by an ExtensionArray are numpy arrays (or slices of a larger numpy array), thenExtensionArrayFormatter
uses Pandas' facilities for rendering numpy arrays. These facilities comprise the base classGenericArrayFormatter
and subclasses such asFloatArrayFormatter
for handling specific types (seepandas/io/formats/format.py
). The formatters for numeric types can render numpy arrays with more than one dimension, but the base classGenericArrayFormatter
cannot. The limitation appears to be an oversight. I will submit a small pull request with a fix in a few minutes.Expected Output
The above code should output something like this:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Darwin
OS-release : 19.4.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.3
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.1.3.post20200330
Cython : 0.29.15
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.13.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : 0.3.3
gcsfs : None
lxml.etree : None
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : 0.8.3
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : 0.49.0
The text was updated successfully, but these errors were encountered: