@@ -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
@@ -1207,10 +1208,10 @@ cdef class TextReader:
1207
1208
na_count = 0
1208
1209
1209
1210
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):
1213
1212
result = result.astype(dtype.numpy_dtype)
1213
+ else :
1214
+ result = result.astype(dtype)
1214
1215
1215
1216
return result, na_count
1216
1217
@@ -1219,10 +1220,10 @@ cdef class TextReader:
1219
1220
na_filter, na_hashset, na_flist)
1220
1221
1221
1222
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):
1225
1224
result = result.astype(dtype.numpy_dtype)
1225
+ else :
1226
+ result = result.astype(dtype)
1226
1227
return result, na_count
1227
1228
1228
1229
elif is_bool_dtype(dtype):
0 commit comments