Skip to content

LazyColumn.str.capitalize

capitalize

capitalize() -> LazyColumn

Capitalizes the first character of each string and converts the rest to lowercase.

Returns:

Name Type Description
LazyColumn LazyColumn

A new LazyColumn with capitalized strings.

Examples:

print(df.head())
#    col1 my_string_column
# 0     1         "hello"
# 1     2         "WORLD"
# 2     3         "123abc"
# 3     4         None
# 4     5         "abc DEF"

df["my_string_column"].str.capitalize()
# ["Hello", "World", "123abc", None, "Abc def"]