Skip to content

Commit

Permalink
Raises a ValueError in PandasColumn._dtype_from_pandasdtype for the f…
Browse files Browse the repository at this point in the history
…ollowing unhandled dtypes: 'b', 'B', 'S', 'a', 'V'.
  • Loading branch information
paulreece committed Sep 30, 2023
1 parent c8e7a98 commit 5f25adf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Numeric

Conversion
^^^^^^^^^^
-
- Raise ValueError in :meth:`PandasColumn._dtype_from_pandasdtype` for currently unhandled dtypes. (:issue:`55332`)
-

Strings
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/interchange/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def _dtype_from_pandasdtype(self, dtype) -> tuple[DtypeKind, int, str, str]:
# Note: 'c' (complex) not handled yet (not in array spec v1).
# 'b', 'B' (bytes), 'S', 'a', (old-style string) 'V' (void) not handled
# datetime and timedelta both map to datetime (is timedelta handled?)
not_handled = ["b", "B", "S", "a", "V"]

kind = _NP_KINDS.get(dtype.kind, None)
if kind is None:
Expand All @@ -143,6 +144,8 @@ def _dtype_from_pandasdtype(self, dtype) -> tuple[DtypeKind, int, str, str]:
byteorder = dtype.numpy_dtype.byteorder
elif isinstance(dtype, DatetimeTZDtype):
byteorder = dtype.base.byteorder # type: ignore[union-attr]
elif dtype.kind in not_handled:
raise ValueError(f"Data type {dtype} not supported by interchange protocol")
else:
byteorder = dtype.byteorder

Expand Down

0 comments on commit 5f25adf

Please sign in to comment.