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 1919)
2020from pandas .core .dtypes .inference import is_integer
2121
22+ from pandas .core .arrays .arrow .array import to_pyarrow_type
23+
2224from pandas .io ._util import arrow_table_to_pandas
2325from pandas .io .parsers .base_parser import ParserBase
2426
@@ -145,20 +147,18 @@ def handle_warning(invalid_row) -> str:
145147 if isinstance (self .dtype , dict ):
146148 column_types = {}
147149 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 )
152151
153152 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 :
158158 # TODO: Unsupported dtypes silently ignored - may cause
159159 # unexpected behavior when pyarrow applies default inference
160160 # instead of user's dtype
161- continue
161+ pass
162162
163163 if column_types :
164164 self .convert_options ["column_types" ] = column_types
You can’t perform that action at this time.
0 commit comments