Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 筛选出列表列表中的元素_List_Apache Spark_Filter_Tuples - Fatal编程技术网

List 筛选出列表列表中的元素

List 筛选出列表列表中的元素,list,apache-spark,filter,tuples,List,Apache Spark,Filter,Tuples,我有以下RDD(列表[列表[字符串]): 我想从每个列表中删除索引0和3处的元素,例如: val removeElements = List(0, 3) data.map(_.zipWithIndex).collect.filter { a => !removeElements.contains(a._2) }.map { _._1 } 但这会导致一个我无法修复的错误: <console>:28: error: value _2 is not a member of List

我有以下RDD(列表[列表[字符串]):

我想从每个列表中删除索引0和3处的元素,例如:

val removeElements = List(0, 3)
data.map(_.zipWithIndex).collect.filter { a => !removeElements.contains(a._2) }.map { _._1 }
但这会导致一个我无法修复的错误:

<console>:28: error: value _2 is not a member of List[(String, Int)]
          data.map(_.zipWithIndex).collect.filter { a => !toRemove.contains(a._2) }.map { _._1 }
我发现只要过滤数据变量使每个变量只有2个元素,就可以使用MyData.tuple(data)


期待在这个问题上有任何帮助

是否要删除或保留这两个值?请共享预期输出。我想删除给定索引中的值。预期的输出将是List(List(“029070”、“99999”)、List(“1”、“N”))data.map(x=>(x(1)、x(2))?
<console>:28: error: value _2 is not a member of List[(String, Int)]
          data.map(_.zipWithIndex).collect.filter { a => !toRemove.contains(a._2) }.map { _._1 }
case class MyData(a: String, b: String)