Note
Kailangan ng pahintulot para ma-access ang page na ito. Maaari mong subukang mag-sign in o magpalit ng mga direktoryo.
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang baguhin ang mga direktoryo.
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
from pyspark.sql import functions as dbf
dbf.translate(srcCol=<srcCol>, matching=<matching>, replace=<replace>)
Parameters
| Parameter | Type | Description |
|---|---|---|
srcCol |
pyspark.sql.Column or str |
Source column or strings |
matching |
str |
matching characters. |
replace |
str |
characters for replacement. If this is shorter than matching string then those chars that don't have replacement will be dropped. |
Returns
pyspark.sql.Column: replaced value.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([('translate',)], ['a'])
df.select('*', dbf.translate('a', "rnlt", "123")).show()