translate
The characters in replace is corresponding to the characters in matching. Translation will happen whenever any character in the string is matching with the character in the matching.
For the corresponding Databricks SQL function, see translate function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.translate(srcCol=<srcCol>, matching=<matching>, replace=<replace>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Source column or strings |
|
| matching characters. |
|
| characters for replacement. If this is shorter than |
Returns
pyspark.sql.Column: replaced value.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('translate',)], ['a'])
df.select('*', dbf.translate('a', "rnlt", "123")).show()