pandas.read_json

pandas 3.1.1 · Input and output · function

Read a JSON file or stream. Set orient for the record layout and lines=True for newline-delimited records.

Call syntax

pd.read_json(…) Full signature
pd.read_json(
    path_or_buf,
    *,
    orient=None,
    typ='frame',
    dtype=None,
    convert_axes=None,
    convert_dates=…,
    keep_default_dates=…,
    precise_float=False,
    date_unit=None,
    encoding=None,
    encoding_errors='strict',
    lines=False,
    chunksize=None,
    compression='infer',
    nrows=None,
    storage_options=None,
    dtype_backend=…,
    engine='ujson',
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
path_or_buf Required
Positional or keyword
a str path, path object or file-like object

Supply a file path or writable/readable stream. Some writers return the result directly when this is omitted.

orient Optional
Keyword only
Default None
str

Choose how row labels, columns, and values are arranged in the serialized result.

typ Optional
Keyword only
Default 'frame'
{'frame', 'series'}
dtype Optional
Keyword only
Default None
bool or dict

Choose the data type for the input conversion or result.

convert_axes Optional
Keyword only
Default None
bool
convert_dates Optional
Keyword only
bool or list of str

Choose which supported values are converted to dates while reading.

keep_default_dates Optional
Keyword only
bool

When omitted, the documented default is True.

precise_float Optional
Keyword only
Default False
bool
date_unit Optional
Keyword only
Default None
str

Choose the timestamp precision in parsed or serialized data.

encoding Optional
Keyword only
Default None
str

Name a text encoding such as "utf-8".

encoding_errors Optional
Keyword only
Default 'strict'
str

Choose how to handle text that cannot be encoded or decoded.

lines Optional
Keyword only
Default False
bool

Choose newline-delimited JSON records where supported.

chunksize Optional
Keyword only
Default None
int

Set how many rows to read or write in each batch.

compression Optional
Keyword only
Default 'infer'
str or dict

Choose whether and how to compress or decompress data.

nrows Optional
Keyword only
Default None
int

Limit the number of rows to read or display.

storage_options Optional
Keyword only
Default None
dict

Pass storage-backend options such as connection settings or HTTP headers.

dtype_backend Optional
Keyword only
{'numpy_nullable', 'pyarrow'}

Choose nullable NumPy-backed dtypes or Arrow-backed dtypes.

engine Optional
Keyword only
Default 'ujson'
{"ujson", "pyarrow"}

Choose the implementation that performs the operation.

Returns

Series, DataFrame, or pandas.api.typing.JsonReader