Skip to content

Extend Series with a constant

Source code

Description

Extend the Series with given number of values.

Usage

<Expr>$extend_constant(value, n)

Arguments

value The value to extend the Series with. This value may be NULL to fill with nulls.
n The number of values to extend.

Value

Expr

Examples

library(polars)

pl$select(pl$lit(1:4)$extend_constant(10.1, 2))
#> shape: (6, 1)
#> ┌─────┐
#> │     │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> │ 4   │
#> │ 10  │
#> │ 10  │
#> └─────┘
pl$select(pl$lit(1:4)$extend_constant(NULL, 2))
#> shape: (6, 1)
#> ┌──────┐
#> │      │
#> │ ---  │
#> │ i32  │
#> ╞══════╡
#> │ 1    │
#> │ 2    │
#> │ 3    │
#> │ 4    │
#> │ null │
#> │ null │
#> └──────┘