Skip to content

Commit 46369f2

Browse files
committed
feat: change type conversion
1 parent bf830f5 commit 46369f2

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

pandas/io/json/_json.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -957,19 +957,13 @@ def _read_pyarrow(self) -> DataFrame:
957957
pyarrow_json = import_optional_dependency("pyarrow.json")
958958
options = None
959959

960-
if isinstance(self.dtype, dict):
961-
pa = import_optional_dependency("pyarrow")
962-
fields = []
963-
for field, dtype in self.dtype.items():
964-
pd_dtype = pandas_dtype(dtype)
965-
if isinstance(pd_dtype, ArrowDtype):
966-
fields.append((field, pd_dtype.pyarrow_dtype))
967-
968-
schema = pa.schema(fields)
969-
options = pyarrow_json.ParseOptions(explicit_schema=schema)
970-
971-
pa_table = pyarrow_json.read_json(self.data, parse_options=options)
972-
return arrow_table_to_pandas(pa_table, dtype_backend=self.dtype_backend)
960+
pa_table = pyarrow_json.read_json(self.data)
961+
df = arrow_table_to_pandas(pa_table, dtype_backend=self.dtype_backend)
962+
963+
if self.dtype:
964+
df = df.astype(self.dtype)
965+
966+
return df
973967

974968
def _read_ujson(self) -> DataFrame | Series:
975969
"""

0 commit comments

Comments
 (0)