polars.Expr.extend_constant#

Expr.extend_constant(value: int | float | str | bool | None, n: int) Expr[source]#

Extend the Series with given number of values.

Parameters:
value

The value to extend the Series with. This value may be None to fill with nulls.

n

The number of values to extend.

Examples

>>> df = pl.DataFrame({"values": [1, 2, 3]})
>>> df.select(pl.col("values").extend_constant(99, n=2))
shape: (5, 1)
┌────────┐
│ values │
│ ---    │
│ i64    │
╞════════╡
│ 1      │
├╌╌╌╌╌╌╌╌┤
│ 2      │
├╌╌╌╌╌╌╌╌┤
│ 3      │
├╌╌╌╌╌╌╌╌┤
│ 99     │
├╌╌╌╌╌╌╌╌┤
│ 99     │
└────────┘