Skip to content

Commit 06d9c01

Browse files
committed
Address merge comments
1 parent c2f519d commit 06d9c01

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
@@ -1229,10 +1230,10 @@ cdef class TextReader:
12291230
na_count = 0
12301231

12311232
if result is not None and dtype != 'int64':
1232-
try:
1233-
result = result.astype(dtype)
1234-
except TypeError:
1233+
if is_extension_array_dtype(dtype):
12351234
result = result.astype(dtype.numpy_dtype)
1235+
else:
1236+
result = result.astype(dtype)
12361237

12371238
return result, na_count
12381239

@@ -1241,10 +1242,10 @@ cdef class TextReader:
12411242
na_filter, na_hashset, na_flist)
12421243

12431244
if result is not None and dtype != 'float64':
1244-
try:
1245-
result = result.astype(dtype)
1246-
except TypeError:
1245+
if is_extension_array_dtype(dtype):
12471246
result = result.astype(dtype.numpy_dtype)
1247+
else:
1248+
result = result.astype(dtype)
12481249
return result, na_count
12491250

12501251
elif is_bool_dtype(dtype):

0 commit comments

Comments
 (0)