I have an RDD structure like:
rdd = [[[1],[2],[3]], [[4],[5]], [[6]], [[7],[8],[9],[10]]]
and I want this to become:
rdd = [1,2,3,4,5,6,7,8,9,10]
How do I write a map or reduce a function to make it work?
You can, for example, flatMapuse lists:
flatMap
rdd.flatMap(lambda xs: [x[0] for x in xs])
or make it a little more general:
from itertools import chain rdd.flatMap(lambda xs: chain(*xs)).collect()
Source: https://habr.com/ru/post/1623676/More articles:Monkey patch against inheritance and overriding in Python - pythonRenderer can not be used in the service? - angularMark text in R - textКак использовать классы Unreal 4 ProcessuralMeshComponent в коде? - c++Formatting IntelliJ JSP - intellij-ideaКак фильтровать несколько значений (операция OR) в javascript - javascriptWhat is the best way to access env variables on the back panel when using the angular -fullstack generator? - javascriptКак изменить название проекта Android React Native - androidHow do you access front-end environment variables when using the Yeoman angular -fullstack generator? - javascriptRun Nim code at compile time - dryAll Articles