Skip to content

Commit 84b8234

Browse files
ignore pandas_metadata for string dtype in case of dictionary column
1 parent fdd6af3 commit 84b8234

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎python/pyarrow/pandas_compat.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,14 @@ def _get_extension_dtypes(
878878
# that are certainly numpy dtypes
879879
pandas_dtype = _pandas_api.pandas_dtype(dtype)
880880
if isinstance(pandas_dtype, _pandas_api.extension_dtype):
881-
if (strings_to_categorical or name in categories) and isinstance(
882-
pandas_dtype, _pandas_api.pd.StringDtype
883-
):
884-
continue
881+
if isinstance(pandas_dtype, _pandas_api.pd.StringDtype):
882+
if strings_to_categorical or name in categories:
883+
continue
884+
try:
885+
if pa.types.is_dictionary(table.schema.field(name).type):
886+
continue
887+
except KeyError:
888+
pass
885889
if hasattr(pandas_dtype, "__from_arrow__"):
886890
ext_columns[name] = pandas_dtype
887891

0 commit comments

Comments
 (0)