我有这种类型的数据结构:
Array(((10359,60),80), ((10442,54),80), ((10440,61),90), ((10324,63),80), ((10286,35),100), ...我想要得到
Array((10359,60,80), (10442,54,80), (10440,61,90), (10324,63,80), (10286,35,100), ...
val maxData = mappedData.reduceByKey((x,y) => math.max(x, y))减少后,我需要得到正确的打印格式,但找不到正确的方法。
val modifiedData = maxData.map(line => (? , ? ,?))?发布于 2016-02-27 17:03:38
val modifiedData = maxData.map(line => (line._1._1,line._1._2,line._2))发布于 2016-02-27 16:51:31
您正在寻找flatten。
scala> val lol = List(List(1,2), List(3,4))
lol: List[List[Int]] = List(List(1, 2), List(3, 4))在此列表列表上调用flatten方法将创建一个新列表:
scala> val result = lol.flatten
result: List[Int] = List(1, 2, 3, 4)https://www.safaribooksonline.com/library/view/scala-cookbook/9781449340292/ch10s16.html
https://stackoverflow.com/questions/35667642
复制相似问题