cudf.core.column.string.StringMethods.translate#
- StringMethods.translate(table: dict) SeriesOrIndex #
Map all characters in the string through the given mapping table.
Equivalent to standard str.translate().
- Parameters
- tabledict
Table is a mapping of Unicode ordinals to Unicode ordinals, strings, or None. Unmapped characters are left untouched. str.maketrans() is a helper function for making translation tables.
- Returns
- Series or Index.
Examples
>>> 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