polars.from_dicts#

polars.from_dicts(dicts: Sequence[dict[str, Any]], infer_schema_length: int | None = 50) DataFrame[source]#

Construct a DataFrame from a sequence of dictionaries. This operation clones data.

Parameters:
dicts

Sequence with dictionaries mapping column name to value

infer_schema_length

How many dictionaries/rows to scan to determine the data types if set to None all rows are scanned. This will be slow.

Returns:
DataFrame

Examples

>>> data = [{"a": 1, "b": 4}, {"a": 2, "b": 5}, {"a": 3, "b": 6}]
>>> df = pl.from_dicts(data)
>>> df
shape: (3, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1   ┆ 4   │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 2   ┆ 5   │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 3   ┆ 6   │
└─────┴─────┘