Right justify strings
Description
Return the string right justified in a string of length
width
.
Usage
<Expr>$str$pad_start(width, fillchar = " ")
Arguments
width
|
Justify right to this length. |
fillchar
|
Fill with this ASCII character. |
Details
Padding is done using the specified fillchar
. The original
string is returned if width
is less than or equal to
len(s)
.
Value
Expr of String
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 │
#> └──────────────┘