Skip to content

LazyColumn.str.strip

strip

strip() -> LazyColumn

Strips whitespace from both ends of the string.

Returns:

Name Type Description
LazyColumn LazyColumn

A new LazyColumn with leading and trailing whitespace removed.

Examples:

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

df["my_string_column"].str.strip()
# ["abc", "def", "xyz", None, "hello"]