aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql
diff options
context:
space:
mode:
Diffstat (limited to 'python/pyspark/sql')
-rw-r--r--python/pyspark/sql/functions.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/pyspark/sql/functions.py b/python/pyspark/sql/functions.py
index 9f0d71d796..b5c6a01f18 100644
--- a/python/pyspark/sql/functions.py
+++ b/python/pyspark/sql/functions.py
@@ -1290,6 +1290,22 @@ def length(col):
return Column(sc._jvm.functions.length(_to_java_column(col)))
+@ignore_unicode_prefix
+@since(1.5)
+def translate(srcCol, matching, replace):
+ """A function translate any character in the `srcCol` by a character in `matching`.
+ The characters in `replace` is corresponding to the characters in `matching`.
+ The translate will happen when any character in the string matching with the character
+ in the `matching`.
+
+ >>> sqlContext.createDataFrame([('translate',)], ['a']).select(translate('a', "rnlt", "123")\
+ .alias('r')).collect()
+ [Row(r=u'1a2s3ae')]
+ """
+ sc = SparkContext._active_spark_context
+ return Column(sc._jvm.functions.translate(_to_java_column(srcCol), matching, replace))
+
+
# ---------------------- Collection functions ------------------------------
@since(1.4)