@@ -38,6 +38,7 @@ from pandas.core.common import (is_categorical_dtype, CategoricalDtype,
38
38
is_integer_dtype, is_float_dtype,
39
39
is_bool_dtype, is_object_dtype,
40
40
is_string_dtype, is_datetime64_dtype)
41
+ from pandas.types.api import pandas_dtype
41
42
from pandas.core.categorical import Categorical
42
43
from pandas.types.concat import union_categoricals
43
44
@@ -492,22 +493,13 @@ cdef class TextReader:
492
493
self .encoding = encoding
493
494
494
495
if isinstance (dtype, dict ):
495
- conv = {}
496
- for k in dtype:
497
- v = dtype[k]
498
- if is_categorical_dtype(v):
499
- v = CategoricalDtype()
500
- elif isinstance (v, basestring ):
501
- v = np.dtype(v)
502
- conv[k] = v
503
- dtype = conv
496
+ dtype = {k: pandas_dtype(dtype[k])
497
+ for k in dtype}
504
498
elif dtype is not None :
505
- if is_categorical_dtype(dtype):
506
- dtype = CategoricalDtype()
507
- else :
508
- dtype = np.dtype(dtype)
499
+ dtype = pandas_dtype(dtype)
509
500
510
501
self .dtype = dtype
502
+ print dtype
511
503
512
504
# XXX
513
505
self .noconvert = set ()
@@ -1101,7 +1093,8 @@ cdef class TextReader:
1101
1093
col_dtype = self .dtype[i]
1102
1094
else :
1103
1095
if self .dtype.names:
1104
- col_dtype = self .dtype.descr[i][1 ]
1096
+ # structured array
1097
+ col_dtype = np.dtype(self .dtype.descr[i][1 ])
1105
1098
else :
1106
1099
col_dtype = self .dtype
1107
1100
@@ -1202,7 +1195,6 @@ cdef class TextReader:
1202
1195
# unicode variable width
1203
1196
return self ._string_convert(i, start, end, na_filter,
1204
1197
na_hashset)
1205
- # is this comparison good enough?
1206
1198
elif is_categorical_dtype(dtype):
1207
1199
codes, cats, na_count = _categorical_convert(self .parser, i, start,
1208
1200
end, na_filter, na_hashset,
0 commit comments