@@ -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
@@ -1229,10 +1230,10 @@ cdef class TextReader:
1229
1230
na_count = 0
1230
1231
1231
1232
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):
1235
1234
result = result.astype(dtype.numpy_dtype)
1235
+ else :
1236
+ result = result.astype(dtype)
1236
1237
1237
1238
return result, na_count
1238
1239
@@ -1241,10 +1242,10 @@ cdef class TextReader:
1241
1242
na_filter, na_hashset, na_flist)
1242
1243
1243
1244
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):
1247
1246
result = result.astype(dtype.numpy_dtype)
1247
+ else :
1248
+ result = result.astype(dtype)
1248
1249
return result, na_count
1249
1250
1250
1251
elif is_bool_dtype(dtype):
0 commit comments