Skip to content

Commit d73558a

Browse files
committed
Handle string dtype better
Signed-off-by: Vasily Litvinov <fam1ly.n4me@yandex.ru>
1 parent 39f5a5c commit d73558a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pandas/core/exchange/column.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import numpy as np
77

8+
from pandas._libs.lib import infer_dtype
89
from pandas.util._decorators import cache_readonly
910

1011
import pandas as pd
@@ -114,10 +115,14 @@ def dtype(self):
114115
Endianness.NATIVE,
115116
)
116117
elif is_string_dtype(dtype):
117-
# TODO: is_string_dtype() can return True for non-string dtypes like
118-
# numpy arrays, because they all have an "object" dtype.
119-
# Think on how to improve the check here.
120-
return (DtypeKind.STRING, 8, dtype_to_arrow_c_fmt(dtype), Endianness.NATIVE)
118+
if infer_dtype(self._col) == "string":
119+
return (
120+
DtypeKind.STRING,
121+
8,
122+
dtype_to_arrow_c_fmt(dtype),
123+
Endianness.NATIVE,
124+
)
125+
raise NotImplementedError("Non-string object dtypes are not supported yet")
121126
else:
122127
return self._dtype_from_pandasdtype(dtype)
123128

0 commit comments

Comments
 (0)