Create a dataframe from a set of JSON files This utilises ``pandas.read_json()``, and most parameters are passed through - see its docstring. Differences: orient is 'records' by default, with lines=True; this is appropriate for line-delimited "JSON-lines" data, the kind of JSON out
(
url_path,
orient="records",
lines=None,
storage_options=None,
blocksize=None,
sample=2**20,
encoding="utf-8",
errors="strict",
compression="infer",
meta=None,
engine=pd.read_json,
include_path_column=False,
path_converter=None,
**kwargs,
)
| 106 | @dataframe_creation_dispatch.register_inplace("pandas") |
| 107 | @insert_meta_param_description |
| 108 | def read_json( |
| 109 | url_path, |
| 110 | orient="records", |
| 111 | lines=None, |
| 112 | storage_options=None, |
| 113 | blocksize=None, |
| 114 | sample=2**20, |
| 115 | encoding="utf-8", |
| 116 | errors="strict", |
| 117 | compression="infer", |
| 118 | meta=None, |
| 119 | engine=pd.read_json, |
| 120 | include_path_column=False, |
| 121 | path_converter=None, |
| 122 | **kwargs, |
| 123 | ): |
| 124 | """Create a dataframe from a set of JSON files |
| 125 | |
| 126 | This utilises ``pandas.read_json()``, and most parameters are |
| 127 | passed through - see its docstring. |
| 128 | |
| 129 | Differences: orient is 'records' by default, with lines=True; this |
| 130 | is appropriate for line-delimited "JSON-lines" data, the kind of JSON output |
| 131 | that is most common in big-data scenarios, and which can be chunked when |
| 132 | reading (see ``read_json()``). All other options require blocksize=None, |
| 133 | i.e., one partition per input file. |
| 134 | |
| 135 | Parameters |
| 136 | ---------- |
| 137 | url_path: str, list of str |
| 138 | Location to read from. If a string, can include a glob character to |
| 139 | find a set of file names. |
| 140 | Supports protocol specifications such as ``"s3://"``. |
| 141 | encoding, errors: |
| 142 | The text encoding to implement, e.g., "utf-8" and how to respond |
| 143 | to errors in the conversion (see ``str.encode()``). |
| 144 | orient, lines, kwargs |
| 145 | passed to pandas; if not specified, lines=True when orient='records', |
| 146 | False otherwise. |
| 147 | storage_options: dict |
| 148 | Passed to backend file-system implementation |
| 149 | blocksize: None or int |
| 150 | If None, files are not blocked, and you get one partition per input |
| 151 | file. If int, which can only be used for line-delimited JSON files, |
| 152 | each partition will be approximately this size in bytes, to the nearest |
| 153 | newline character. |
| 154 | sample: int |
| 155 | Number of bytes to pre-load, to provide an empty dataframe structure |
| 156 | to any blocks without data. Only relevant when using blocksize. |
| 157 | encoding, errors: |
| 158 | Text conversion, ``see bytes.decode()`` |
| 159 | compression : string or None |
| 160 | String like 'gzip' or 'xz'. |
| 161 | engine : callable or str, default ``pd.read_json`` |
| 162 | The underlying function that dask will use to read JSON files. By |
| 163 | default, this will be the pandas JSON reader (``pd.read_json``). |
| 164 | If a string is specified, this value will be passed under the ``engine`` |
| 165 | key-word argument to ``pd.read_json`` (only supported for pandas>=2.0). |
nothing calls this directly
no test coverage detected