按数组列过滤Scala数据框

数字和

我的 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

Manoj Kumar 达卡德

您可以使用array_contains功能

import org.apache.spark.sql.functions._

df.filter(array_contains(df.col("my_column"), "hello")).show

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章