source: str | Path | IOBase | bytes,
schema: SchemaDefinition | None = None,
schema_overrides: SchemaDefinition | None = None,
ignore_errors: bool = False,
) DataFrame[source]#

Read into a DataFrame from a newline delimited JSON file.


Path to a file or a file-like object (by “file-like object” we refer to objects that have a read() method, such as a file handler like the builtin open function, or a BytesIO instance).

schemaSequence of str, (str,DataType) pairs, or a {str:DataType,} dict

The DataFrame schema may be declared in several ways:

  • As a dict of {name:type} pairs; if type is None, it will be auto-inferred.

  • As a list of column names; in this case types are automatically inferred.

  • As a list of (name,type) pairs; this is equivalent to the dictionary form.

If you supply a list of column names that does not match the names in the underlying data, the names given here will overwrite them. The number of names given in the schema should match the underlying data dimensions.

schema_overridesdict, default None

Support type specification or override of one or more columns; note that any dtypes inferred from the schema param will be overridden.


Return Null if parsing fails because of schema mismatches.


>>> from io import StringIO
>>> json_str = '{"foo":1,"bar":6}\n{"foo":2,"bar":7}\n{"foo":3,"bar":8}\n'
>>> pl.read_ndjson(StringIO(json_str))
shape: (3, 2)
│ foo ┆ bar │
│ --- ┆ --- │
│ i64 ┆ i64 │
│ 1   ┆ 6   │
│ 2   ┆ 7   │
│ 3   ┆ 8   │