Skip to content

Commit 5f25adf

Browse files
committed
Raises a ValueError in PandasColumn._dtype_from_pandasdtype for the following unhandled dtypes: 'b', 'B', 'S', 'a', 'V'.
1 parent c8e7a98 commit 5f25adf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

doc/source/whatsnew/v2.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Numeric
280280

281281
Conversion
282282
^^^^^^^^^^
283-
-
283+
- Raise ValueError in :meth:`PandasColumn._dtype_from_pandasdtype` for currently unhandled dtypes. (:issue:`55332`)
284284
-
285285

286286
Strings

pandas/core/interchange/column.py

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def _dtype_from_pandasdtype(self, dtype) -> tuple[DtypeKind, int, str, str]:
134134
# Note: 'c' (complex) not handled yet (not in array spec v1).
135135
# 'b', 'B' (bytes), 'S', 'a', (old-style string) 'V' (void) not handled
136136
# datetime and timedelta both map to datetime (is timedelta handled?)
137+
not_handled = ["b", "B", "S", "a", "V"]
137138

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

0 commit comments

Comments
 (0)