Skip to content

Commit c2f519d

Browse files
committed
ENH:Add EA types to read CSV
Closes GH23228
1 parent dc8d35a commit c2f519d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pandas/_libs/parsers.pyx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,10 @@ cdef class TextReader:
12291229
na_count = 0
12301230

12311231
if result is not None and dtype != 'int64':
1232-
result = result.astype(dtype)
1232+
try:
1233+
result = result.astype(dtype)
1234+
except TypeError:
1235+
result = result.astype(dtype.numpy_dtype)
12331236

12341237
return result, na_count
12351238

@@ -1238,7 +1241,10 @@ cdef class TextReader:
12381241
na_filter, na_hashset, na_flist)
12391242

12401243
if result is not None and dtype != 'float64':
1241-
result = result.astype(dtype)
1244+
try:
1245+
result = result.astype(dtype)
1246+
except TypeError:
1247+
result = result.astype(dtype.numpy_dtype)
12421248
return result, na_count
12431249

12441250
elif is_bool_dtype(dtype):

pandas/core/dtypes/common.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,10 @@ def _get_dtype_type(arr_or_dtype):
19041904
try:
19051905
return arr_or_dtype.dtype.type
19061906
except AttributeError:
1907-
return type(None)
1907+
try:
1908+
return arr_or_dtype.numpy_dtype.type
1909+
except AttributeError:
1910+
return type(None)
19081911

19091912

19101913
def _get_dtype_from_object(dtype):

pandas/tests/io/parser/common.py

Whitespace-only changes.

0 commit comments

Comments
 (0)