我尝试使用之前定义的函数在PySpark DataFrame中添加列。功能是:
def is_company(name,cut):
score = 0
for i in name:
if i in list:
score =+ 1
else:
score = score
if score >= cut:
return 1
else:
return 0
其中" list"是包含公司名称中最常见单词的列表。 然后,我有一个数据框,其中一列是公司和人名,我在列中应用函数,如下所示:
df_person.withColumn('is_empresa_col', is_company('apnomper',2))
我不知道为什么这不起作用。错误是:
AssertionError: col should be Column