用法:
StringMethods.pad(width: int, side: str = 'left', fillchar: str = ' ') → SeriesOrIndex
將係列/索引中的字符串填充到寬度。
- width:int
結果字符串的最小寬度;額外的字符將用 fillchar 中定義的字符填充。
- side:{‘left’, ‘right’, ‘both’},默認 ‘left’
填充結果字符串的一側。
- fillchar:str,默認“”(空格)
用於填充的附加字符,默認為空格。
- 對象的係列/索引
返回對象中字符數最少的係列或索引。
參數:
返回:
例子:
>>> 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
相關用法
- Python cudf.core.column.string.StringMethods.partition用法及代碼示例
- Python cudf.core.column.string.StringMethods.porter_stemmer_measure用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python cudf.core.column.string.StringMethods.endswith用法及代碼示例
- Python cudf.core.column.string.StringMethods.title用法及代碼示例
- Python cudf.core.column.string.StringMethods.contains用法及代碼示例
- Python cudf.core.column.string.StringMethods.rsplit用法及代碼示例
- Python cudf.core.column.string.StringMethods.zfill用法及代碼示例
- Python cudf.core.column.string.StringMethods.hex_to_int用法及代碼示例
- Python cudf.core.column.string.StringMethods.htoi用法及代碼示例
- Python cudf.core.column.string.StringMethods.character_tokenize用法及代碼示例
- Python cudf.core.column.string.StringMethods.normalize_characters用法及代碼示例
- Python cudf.core.column.string.StringMethods.filter_alphanum用法及代碼示例
- Python cudf.core.column.string.StringMethods.split用法及代碼示例
- Python cudf.core.column.string.StringMethods.ngrams用法及代碼示例
- Python cudf.core.column.string.StringMethods.replace_with_backrefs用法及代碼示例
- Python cudf.core.column.string.StringMethods.insert用法及代碼示例
- Python cudf.core.column.string.StringMethods.replace用法及代碼示例
- Python cudf.core.column.string.StringMethods.rstrip用法及代碼示例
- Python cudf.core.column.string.StringMethods.replace_tokens用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.core.column.string.StringMethods.pad。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。