且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PySpark中替换字符串

更新时间:2023-11-13 22:10:40

您需要转义进行字面匹配,如是一个特殊字符,匹配正则表达式中的几乎所有字符

You need to escape . to match it literally, as . is a special character that matches almost any character in regex:

df = df.withColumn('revenue', regexp_replace(col('revenue'), "\\.", ""))