Note
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. 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.
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')]