pyspark.sql.functions.replace(src: ColumnOrName, search: ColumnOrName, replace: Optional[ColumnOrName] = None) → pyspark.sql.column.Column[source]

Replaces all occurrences of search with replace.

New in version 3.5.0.

srcColumn or str

A column of string to be replaced.

searchColumn or str

A column of string, If search is not found in str, str is returned unchanged.

replaceColumn 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.


>>> df = spark.createDataFrame([("ABCabc", "abc", "DEF",)], ["a", "b", "c"])
>>>, df.b, df.c).alias('r')).collect()
>>>, df.b).alias('r')).collect()