Skip to content

Commit bd0b9b7

Browse files
committed
Address merge comments
1 parent afb801f commit bd0b9b7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pandas/_libs/parsers.pyx

+8-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ from pandas.core.dtypes.common import (
5050
is_integer_dtype, is_float_dtype,
5151
is_bool_dtype, is_object_dtype,
5252
is_datetime64_dtype,
53-
pandas_dtype)
53+
pandas_dtype, is_extension_array_dtype,
54+
)
5455
from pandas.core.arrays import Categorical
5556
from pandas.core.dtypes.concat import union_categoricals
5657
import pandas.io.common as icom
@@ -1207,10 +1208,10 @@ cdef class TextReader:
12071208
na_count = 0
12081209

12091210
if result is not None and dtype != 'int64':
1210-
try:
1211-
result = result.astype(dtype)
1212-
except TypeError:
1211+
if is_extension_array_dtype(dtype):
12131212
result = result.astype(dtype.numpy_dtype)
1213+
else:
1214+
result = result.astype(dtype)
12141215

12151216
return result, na_count
12161217

@@ -1219,10 +1220,10 @@ cdef class TextReader:
12191220
na_filter, na_hashset, na_flist)
12201221

12211222
if result is not None and dtype != 'float64':
1222-
try:
1223-
result = result.astype(dtype)
1224-
except TypeError:
1223+
if is_extension_array_dtype(dtype):
12251224
result = result.astype(dtype.numpy_dtype)
1225+
else:
1226+
result = result.astype(dtype)
12261227
return result, na_count
12271228

12281229
elif is_bool_dtype(dtype):

0 commit comments

Comments
 (0)