הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
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()