我的 scala 数据框有一列具有数据类型array
( element: String
)。我想显示该列中包含“hello”一词的数据帧行。
我有这个:
display(df.filter($"my_column".contains("hello")))
由于数据不匹配,我收到错误消息。它说argument 1 requires string type, however, '
my:column ' is of array<string> type
。
您可以使用array_contains
功能
import org.apache.spark.sql.functions._
df.filter(array_contains(df.col("my_column"), "hello")).show
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句