You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importpandasaspd# pandas 2.2.3 => latestimportpyarrowaspa# pyarrow 17.0.0 => latesttab=pa.table({"names": pa.array(["a", "b", "c"], type=pa.string_view())})
# this succeedstab.to_pandas()
# this throws an exceptiontab.to_pandas(types_mapper=pd.ArrowDtype)
Issue Description
Our library is producing Arrow binary view arrays (strings and binary) and we want to allow users to convert into Pandas DataFrame.
We are using the pd.ArrowDtype constructor to allow creating Pandas arrays that are backed with Arrow storage. The example I've attached fails also when you change "c" to None (i.e. problem hits for both nullable and non-nullable types).
Full repro with error message:
>>> import pandas as pd # pandas 2.2.3 => latest
>>> import pyarrow as pa # pyarrow 17.0.0 => latest
>>>
>>> tab = pa.table({"names": pa.array(["a", "b", "c"], type=pa.string_view())})
>>>
>>> # this succeeds
>>> tab.to_pandas()
names
0 a
1 b
2 c
>>>
>>> # this throws an exception
>>> tab.to_pandas(types_mapper=pd.ArrowDtype)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 1214, in __repr__
return self.to_string(**repr_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/util/_decorators.py", line 333, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/core/frame.py", line 1394, in to_string
return fmt.DataFrameRenderer(formatter).to_string(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/format.py", line 962, in to_string
string = string_formatter.to_string()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/string.py", line 29, in to_string
text = self._get_string_representation()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/string.py", line 44, in _get_string_representation
strcols = self._get_strcols()
^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/string.py", line 35, in _get_strcols
strcols = self.fmt.get_strcols()
^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/format.py", line 476, in get_strcols
strcols = self._get_strcols_without_index()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/format.py", line 729, in _get_strcols_without_index
str_columns = self._get_formatted_column_labels(self.tr_frame)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/io/formats/format.py", line 809, in _get_formatted_column_labels
need_leadsp = dict(zip(fmt_columns, map(is_numeric_dtype, dtypes)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/core/dtypes/common.py", line 1119, in is_numeric_dtype
return _is_dtype_type(
^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/core/dtypes/common.py", line 1468, in _is_dtype_type
tipo = pandas_dtype(arr_or_dtype).type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Code/vortex/.venv/lib/python3.11/site-packages/pandas/core/dtypes/dtypes.py", line 2169, in type
raise NotImplementedError(pa_type)
NotImplementedError: string_view
>>>
The failure is occurring in the type property accessor on ArrowDtype. I'm not familiar enough with Pandas internals to be sure, but my suspicion is that this if statement should include a check for is_string_view
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
Our library is producing Arrow binary view arrays (strings and binary) and we want to allow users to convert into Pandas DataFrame.
We are using the
pd.ArrowDtype
constructor to allow creating Pandas arrays that are backed with Arrow storage. The example I've attached fails also when you change"c"
toNone
(i.e. problem hits for both nullable and non-nullable types).Full repro with error message:
This seems like a distinct issue from #59883.
Expected Behavior
I'd expect the throwing example to not throw.
Installed Versions
Device: macOS 14.4.1 M2 Max MBP
The text was updated successfully, but these errors were encountered: