用法:
StringMethods.replace_tokens(targets, replacements, delimiter: str = None) → SeriesOrIndex
在係列中的每個字符串中搜索目標標記,如果找到,則用相應的替換項替換。令牌由提供的分隔符標識。
- targets:array-like,序列或係列
要在每個字符串中搜索的標記。
- replacements:array-like、序列、係列或字符串
為找到的每個找到的目標令牌替換的字符串。或者,這可以是單個 str 實例,並將用作找到的每個字符串的替換。
- delimiter:str
用於定位每個字符串的標記的字符。默認為空格。
- 對象的係列或索引。
參數:
返回:
例子:
>>> import cudf >>> sr = cudf.Series(["this is me", "theme music", ""]) >>> targets = cudf.Series(["is", "me"]) >>> sr.str.replace_tokens(targets=targets, replacements="_") 0 this _ _ 1 theme music 2 dtype: object >>> sr = cudf.Series(["this;is;me", "theme;music", ""]) >>> sr.str.replace_tokens(targets=targets, replacements=":") 0 this;is;me 1 theme;music 2 dtype: object
相關用法
- Python cudf.core.column.string.StringMethods.replace_with_backrefs用法及代碼示例
- Python cudf.core.column.string.StringMethods.replace用法及代碼示例
- Python cudf.core.column.string.StringMethods.repeat用法及代碼示例
- Python cudf.core.column.string.StringMethods.rsplit用法及代碼示例
- Python cudf.core.column.string.StringMethods.rstrip用法及代碼示例
- Python cudf.core.column.string.StringMethods.rfind用法及代碼示例
- Python cudf.core.column.string.StringMethods.rindex用法及代碼示例
- Python cudf.core.column.string.StringMethods.rpartition用法及代碼示例
- Python cudf.core.column.string.StringMethods.rjust用法及代碼示例
- 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.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用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.core.column.string.StringMethods.replace_tokens。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。