@@ -50,7 +50,8 @@ from pandas.core.dtypes.common import (
50
50
is_integer_dtype, is_float_dtype,
51
51
is_bool_dtype, is_object_dtype,
52
52
is_datetime64_dtype,
53
- pandas_dtype)
53
+ pandas_dtype, is_extension_array_dtype,
54
+ )
54
55
from pandas.core.arrays import Categorical
55
56
from pandas.core.dtypes.concat import union_categoricals
56
57
import pandas.io.common as icom
@@ -1195,10 +1196,10 @@ cdef class TextReader:
1195
1196
na_count = 0
1196
1197
1197
1198
if result is not None and dtype != ' int64' :
1198
- try :
1199
- result = result.astype(dtype)
1200
- except TypeError :
1199
+ if is_extension_array_dtype(dtype):
1201
1200
result = result.astype(dtype.numpy_dtype)
1201
+ else :
1202
+ result = result.astype(dtype)
1202
1203
1203
1204
return result, na_count
1204
1205
@@ -1207,10 +1208,10 @@ cdef class TextReader:
1207
1208
na_filter, na_hashset, na_flist)
1208
1209
1209
1210
if result is not None and dtype != ' float64' :
1210
- try :
1211
- result = result.astype(dtype)
1212
- except TypeError :
1211
+ if is_extension_array_dtype(dtype):
1213
1212
result = result.astype(dtype.numpy_dtype)
1213
+ else :
1214
+ result = result.astype(dtype)
1214
1215
return result, na_count
1215
1216
1216
1217
elif is_bool_dtype(dtype):
0 commit comments