File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 19
19
)
20
20
from pandas .core .dtypes .inference import is_integer
21
21
22
+ from pandas .core .arrays .arrow .array import to_pyarrow_type
23
+
22
24
from pandas .io ._util import arrow_table_to_pandas
23
25
from pandas .io .parsers .base_parser import ParserBase
24
26
@@ -145,20 +147,18 @@ def handle_warning(invalid_row) -> str:
145
147
if isinstance (self .dtype , dict ):
146
148
column_types = {}
147
149
for col , col_dtype in self .dtype .items ():
148
- # TODO: Category dtypes are not currently handled - may cause issues
149
- # with categorical data preservation in pyarrow engine
150
- if col_dtype == "category" :
151
- continue
150
+ source_dtype = pandas_dtype (col_dtype )
152
151
153
152
try :
154
- numpy_dtype = pandas_dtype (col_dtype ).type
155
- pyarrow_dtype = pa .from_numpy_dtype (numpy_dtype )
156
- column_types [col ] = pyarrow_dtype
157
- except (ValueError , pa .ArrowNotImplementedError ):
153
+ target_dtype = to_pyarrow_type (source_dtype )
154
+ if target_dtype :
155
+ column_types [col ] = target_dtype
156
+
157
+ except TypeError :
158
158
# TODO: Unsupported dtypes silently ignored - may cause
159
159
# unexpected behavior when pyarrow applies default inference
160
160
# instead of user's dtype
161
- continue
161
+ pass
162
162
163
163
if column_types :
164
164
self .convert_options ["column_types" ] = column_types
You can’t perform that action at this time.
0 commit comments