我在我的pyspark数据帧上使用pyspark.ml.feature.StopWordsRemover类.它有ID和Text列.除了提供的默认停用词列表,我想添加自己的自定义列表以从字符串中删除所有数值.
我可以看到有一个方法可以为这个类添加setStopWords.我想我正在努力使用正确的语法来使用这种方法.
from pyspark.sql.functions import *
from pyspark.ml.feature import *
a = StopWordsRemover(inputCol="words", outputCol="filtered")
b = a.transform(df)
Run Code Online (Sandbox Code Playgroud)
上面的代码在过滤列中给出了预期结果,但它只删除/停止标准单词.我正在寻找一种方法来添加我自己的自定义列表,该列表将包含我希望过滤的更多单词和数值.
我有以下带有复杂数据类型STRUCT的配置单元表。您可以帮忙为特定城市的where子句编写蜂巢查询吗?
CREATE EXTERNAL TABLE user_t (
name STRING,
id BIGINT,
isFTE BOOLEAN,
role VARCHAR(64),
salary DECIMAL(8,2),
phones ARRAY<INT>,
deductions MAP<STRING, FLOAT>,
address ARRAY<STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>>,
others UNIONTYPE<FLOAT,BOOLEAN,STRING>,
misc BINARY
)
Run Code Online (Sandbox Code Playgroud)
我可以在select子句中使用STRUCT数据类型,但不能在where子句中使用相同的数据类型。
工作方式:
select address.city from user_t;
Run Code Online (Sandbox Code Playgroud)
无法运作:
select address.city from user_t where address.city = 'XYZ'
Run Code Online (Sandbox Code Playgroud)
文档说它在使用group by或where子句时有局限性,并且也给出了解决方案。但是我不清楚。
链接:文档
请提出建议。谢谢。