หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
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')]