Spec-Zone.ru › Polars

polars.Expr.explode

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

Explode a list expression.

This means that every item is expanded to a new row.

engine:In MemoryStreamingDistributed
Parameters:
empty_as_null

Explode an empty list/array into a null.

keep_nulls

Explode a null list/array into a null.

Returns:
Expr

Expression with the data type of the list elements.

See also

Expr.list.explode

Explode a list column.

Examples

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

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

Spec-Zone.ru

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