maxframe.dataframe.Series.str.translate#

Series.str.translate(table)#

Map all characters in the string through the given mapping table.

This method is equivalent to the standard str.translate() method for strings. It maps each character in the string to a new character according to the translation table provided. Unmapped characters are left unchanged, while characters mapped to None are removed.

Parameters:

table (dict) – 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:

A new Series or Index with translated strings.

Return type:

Series or Index

See also

Series.str.replace

Replace occurrences of pattern/regex in the Series with some other string.

Index.str.replace

Replace occurrences of pattern/regex in the Index with some other string.

Examples

>>> import maxframe.dataframe as md
>>> ser = md.Series(["El niño", "Françoise"])
>>> mytable = str.maketrans({"ñ": "n", "ç": "c"})
>>> ser.str.translate(mytable).execute()
0   El nino
1   Francoise
dtype: str