【发布时间】:2022-01-06 05:51:48
【问题描述】:
我是第一次使用 PySpark,我快疯了。尽管有过滤器功能,但似乎没有从我的 df 中过滤出 None 值。
from nltk.stem.porter import PorterStemmer
from pyspark.sql.functions import col
stemmer = PorterStemmer()
articles = articles.rdd \
.map(lambda r: (" ".join(stemmer.stem(r["content"])),)) \
.toDF(["content"]) \
.where(col("content").isNotNull())
print(articles.count())
这是我得到的错误:
org.apache.spark.SparkException:
作业因阶段失败而中止:
阶段 359.0 中的任务 2 失败 1 次,最近一次失败:在阶段 359.0 中丢失任务 2.0 org.apache.spark.api.python.PythonException:
'AttributeError: 'NoneType' object has no attribute 'lower' ', 从
,第 11 行。
完整的追溯如下:...
我怀疑地图或 lambda 函数是罪魁祸首,因为如果我将其更改为
lambda r: ('stemmer.stem(r["content"])',).
然后它突然起作用了。
您认为是什么导致了我的问题? 还是应该尝试其他方法来映射列?
【问题讨论】:
标签: python dataframe apache-spark pyspark rdd