【发布时间】:2024-01-03 09:19:01
【问题描述】:
我是pyspark 的新手,想将我现有的pandas / python 代码翻译成PySpark。
我想对我的dataframe 进行子集化,以便只返回包含我在'original_problem' 字段中查找的特定关键字的行。
下面是我在 PySpark 中尝试过的 Python 代码:
def pilot_discrep(input_file):
df = input_file
searchfor = ['cat', 'dog', 'frog', 'fleece']
df = df[df['original_problem'].str.contains('|'.join(searchfor))]
return df
当我尝试运行上述内容时,我收到以下错误:
AnalysisException: u"Can't extract value from original_problem#207: 需要结构类型但得到字符串;"
【问题讨论】:
标签: string search pyspark substring subset