【发布时间】:2018-12-21 08:43:58
【问题描述】:
我有这个小脚本来过滤包含liste值的单词
当我这样做时:
它显示:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'filter'
我该如何纠正它? 谢谢
【问题讨论】:
-
您好,您正在尝试在 python 字符串上使用 Pyspark Dataframe 方法(
where()这是filter()的别名)。如果你想使用where(),你需要创建一个 pyspark 数据框。如果你想保留这个字符串(我认为没有必要将这个字符串分布在多个节点上),你需要使用可以从字符串中调用的方法。请注意变量的名称,有时您将名称“列表”用于str对象,这令人不安。 docs.python.org/3.7/library/string.html -
@CorentinLimier 谢谢
-
如何将 listeexclure="AIDE_EN;toCCto;tita" 转换为 Dataframe ?我试过 df = sc.toDF(listeexclure) 但它显示 AttributeError: 'SparkContext' object has no attribute 'toDF'
标签: python apache-spark