pyspark.pandas.Series.str.translate

str.translate(table: Dict) → pyspark.pandas.series.Series

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. Characters mapped to None are deleted. str.maketrans() is a helper function for making translation tables.

Returns
Series of object

Series with translated strings.

Examples

>>> s = ps.Series(["dog", "cat", "bird"])
>>> m = str.maketrans({'a': 'X', 'i': 'Y', 'o': None})
>>> s.str.translate(m)
0      dg
1     cXt
2    bYrd
dtype: object