Skip to content

Right justify strings

Description

Return the string right justified in a string of length length.

Usage

<Expr>$str$pad_start(length, fill_char = " ")

Arguments

length Justify right to this length.
fill_char Fill with this ASCII character.

Details

Padding is done using the specified fill_char. The original string is returned if length is less than or equal to len(s).

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = c("cow", "monkey", NA, "hippopotamus"))
df$select(pl$col("a")$str$pad_start(8, "*"))
#> shape: (4, 1)
#> ┌──────────────┐
#> │ a            │
#> │ ---          │
#> │ str          │
#> ╞══════════════╡
#> │ *****cow     │
#> │ **monkey     │
#> │ null         │
#> │ hippopotamus │
#> └──────────────┘