Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/7468#discussion_r34932187
--- Diff: python/pyspark/sql/functions.py ---
@@ -340,6 +342,34 @@ def levenshtein(left, right):
@ignore_unicode_prefix
@since(1.5)
+def regex_extract(str, pattern, idx):
+ """Extract a specific(idx) group identified by a java regex, from the
specified string column.
+
+ >>> df0 = sqlContext.createDataFrame([('100-200', '',)], ['str',
'dummy'])
+ >>> df0.select(regex_extract('str', '(\d+)-(\d+)',
1).alias('d')).collect()
+ [Row(d=u'100')]
+ """
+ sc = SparkContext._active_spark_context
+ jc = sc._jvm.functions.regex_extract(_to_java_column(str), pattern,
idx)
+ return Column(jc)
+
+
+@ignore_unicode_prefix
+@since(1.5)
+def regex_replace(str, pattern, replacement):
+ """Replace all substrings of the specified string value that match
regexp with rep.
+
+ >>> df0 = sqlContext.createDataFrame([('100-200', '',)], ['str',
'dummy'])
--- End diff --
Create a single item tuple:`(xxx,)`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]