Spec-Zone.ru › Polars

polars.Expr.list.explode

Expr.list.explode(
    *,
    empty_as_null: bool = <object object>,
    keep_nulls: bool = True,
) → Expr

Returns a column with a separate row for every sub-list.

engine:In MemoryStreamingDistributed
Parameters:
empty_as_null

Explode an empty list into a null.

keep_nulls

Explode a null list into a null.

Returns:
Expr

Expression with the data type of the list elements.

See also

Expr.reshape

Reshape this Expr to a flat Series or a Series of Lists.

Examples

>>> df = pl.DataFrame({"a": [[1, 2, 3], [4, 5, 6]]})
>>> df.select(pl.col("a").list.explode(empty_as_null=False))
shape: (6, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 2   │
│ 3   │
│ 4   │
│ 5   │
│ 6   │
└─────┘

© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.list.explode.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API