Skip to content

LazyColumn.str.rjust

rjust

rjust(width: int, fillchar: str = ' ') -> LazyColumn

Right-justifies the string within a field of the specified width, padding with fillchar on the left.

Parameters:

Name Type Description Default
width int

The total width of the resulting string after padding.

required
fillchar str

The character to use for left-side padding. Defaults to a space.

' '

Returns:

Name Type Description
LazyColumn LazyColumn

A new LazyColumn with strings right-justified to the given width.

Examples:

print(df.head())
#    col1 my_string_column
# 0     1         "abc"
# 1     2         "1234"
# 2     3         None
# 3     4        "hello"
# 4     5         "x"

df["my_string_column"].str.rjust(5, "*")
# ["**abc", "*1234", None, "*hello", "****x"]