【发布时间】:2019-09-21 09:22:19
【问题描述】:
我正在尝试使用正则表达式从我的标记化文本中删除标点符号。我正在使用火花数据框。 这是我的功能:
def removePunctuation(column):
return trim(lower(regexp_replace(column,'[^\sa-zA-Z0-9]', ''))).alias('stopped')
当我通过以下方式执行此功能时:
removed_df.select(removePunctuation(col('stopped'))).show(truncate=False)
我有错误:
Py4JJavaError: An error occurred while calling o736.select.
: org.apache.spark.sql.AnalysisException: cannot resolve 'regexp_replace(`stopped`, '[^\\sa-zA-Z0-9]', '')' due to data type mismatch: argument 1 requires string type, however, '`stopped`' is of array<string> type.;;
有没有办法通过这个函数来删除标点符号?它有什么问题?
【问题讨论】:
标签: dataframe pyspark punctuation