cudf.core.column.string.StringMethods.translate#
- StringMethods.translate(table: dict) SeriesOrIndex[source]#
通过给定的映射表映射字符串中的所有字符。
等同于标准的str.translate()。
- Parameters:
- tabledict
Table 是 Unicode 序数到 Unicode 序数、字符串或 None 的映射。 未映射的字符保持不变。 str.maketrans() 是一个用于创建翻译表的辅助函数。
- Returns:
- Series or Index.
示例
>>> import cudf >>> data = ['lower', 'CAPITALS', 'this is a sentence','SwApCaSe'] >>> s = cudf.Series(data) >>> s.str.translate({'a': "1"}) 0 lower 1 CAPITALS 2 this is 1 sentence 3 SwApC1Se dtype: object >>> s.str.translate({'a': "1", "e":"#"}) 0 low#r 1 CAPITALS 2 this is 1 s#nt#nc# 3 SwApC1S# dtype: object