File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 32
32
from pandas .core .dtypes .common import (
33
33
ensure_str ,
34
34
is_string_dtype ,
35
+ pandas_dtype ,
35
36
)
36
37
from pandas .core .dtypes .dtypes import PeriodDtype
37
38
@@ -939,7 +940,19 @@ def read(self) -> DataFrame | Series:
939
940
with self :
940
941
if self .engine == "pyarrow" :
941
942
pyarrow_json = import_optional_dependency ("pyarrow.json" )
942
- pa_table = pyarrow_json .read_json (self .data )
943
+ if isinstance (self .dtype , dict ):
944
+ pa = import_optional_dependency ("pyarrow" )
945
+ fields = [
946
+ (field , pandas_dtype (dtype ).pyarrow_dtype )
947
+ for field , dtype in self .dtype .items ()
948
+ ]
949
+ schema = pa .schema (fields )
950
+ pa_table = pyarrow_json .read_json (
951
+ self .data ,
952
+ parse_options = pyarrow_json .ParseOptions (explicit_schema = schema ),
953
+ )
954
+ else :
955
+ pa_table = pyarrow_json .read_json (self .data )
943
956
944
957
mapping : type [ArrowDtype ] | None | Callable
945
958
if self .dtype_backend == "pyarrow" :
You can’t perform that action at this time.
0 commit comments