cudf.core.column.string.StringMethods.pad#
- StringMethods.pad(width: int, side: str = 'left', fillchar: str = ' ') SeriesOrIndex[source]#
将Series/Index中的字符串填充到指定宽度。
- Parameters:
- widthint
结果字符串的最小宽度; 额外的字符将用fillchar定义的字符填充。
- side{‘left’, ‘right’, ‘both’}, default ‘left’
从哪一侧填充结果字符串。
- fillcharstr, default ‘ ‘ (whitespace)
用于填充的额外字符,默认为空格。
- Returns:
- Series/Index of object
返回对象中字符数最少的Series或Index。
另请参阅
示例
>>> import cudf >>> s = cudf.Series(["caribou", "tiger"])
>>> s.str.pad(width=10) 0 caribou 1 tiger dtype: object
>>> s.str.pad(width=10, side='right', fillchar='-') 0 caribou--- 1 tiger----- dtype: object
>>> s.str.pad(width=10, side='both', fillchar='-') 0 -caribou-- 1 --tiger--- dtype: object