polars.Series.str.strip_chars_end#

Series.str.strip_chars_end(characters: IntoExprColumn | None = None) Series[source]#

移除尾部字符。

Parameters:
characters

要移除的字符集。该字符集的所有组合将从字符串的末尾移除。如果设置为None(默认值),则改为移除所有尾随空白字符。

示例

>>> s = pl.Series([" hello ", "world\t"])
>>> s.str.strip_chars_end()
shape: (2,)
Series: '' [str]
[
        " hello"
        "world"
]

可以通过传递字符串作为参数来去除字符。请注意,这样做时空白字符不会自动去除。

>>> s.str.strip_chars_end("orld\t")
shape: (2,)
Series: '' [str]
[
    " hello "
    "w"
]