Σημείωση
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να συνδεθείτε ή να αλλάξετε καταλόγους.
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να αλλάξετε καταλόγους.
Replaces all occurrences of search with replace.
For the corresponding Databricks SQL function, see replace function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.replace(src=<src>, search=<search>, replace=<replace>)
Parameters
| Parameter | Type | Description |
|---|---|---|
src |
pyspark.sql.Column or str |
A column of string to be replaced. |
search |
pyspark.sql.Column or str |
A column of string, If search is not found in str, str is returned unchanged. |
replace |
pyspark.sql.Column or str, optional |
A column of string, If replace is not specified or is an empty string, nothing replaces the string that is removed from str. |
Examples
df = spark.createDataFrame([("ABCabc", "abc", "DEF",)], ["a", "b", "c"])
df.select(replace(df.a, df.b, df.c).alias('r')).collect()
[Row(r='ABCDEF')]
df.select(replace(df.a, df.b).alias('r')).collect()
[Row(r='ABC')]