cudf.core.column.string.StringMethods.ljust#

StringMethods.ljust(width: int, fillchar: str = ' ') SeriesOrIndex[source]#

在Series/Index的字符串右侧填充一个额外的字符。等同于str.ljust()

Parameters:
widthint

结果字符串的最小宽度; 额外的字符将用 fillchar 填充。

fillcharstr, default ‘ ‘ (whitespace)

用于填充的额外字符,默认为空格。

Returns:
Series/Index of str dtype

返回 Series 或 Index。

示例

>>> import cudf
>>> s = cudf.Series(["hello world", "rapids ai"])
>>> s.str.ljust(10, fillchar="_")
0    hello world
1     rapids ai_
dtype: object
>>> s = cudf.Series(["a", "",  "ab", "__"])
>>> s.str.ljust(1, fillchar="-")
0     a
1     -
2    ab
3    __
dtype: object