pyspark.RDD.flatMapValues#
- RDD.flatMapValues(f)[source]#
Pass each value in the key-value pair RDD through a flatMap functionwithout changing the keys; this also retains the original RDD’spartitioning.
New in version 0.7.0.
- Parameters
- ffunction
a function to turn a V into a sequence of U
- Returns
See also
Examples
>>>rdd=sc.parallelize([("a",["x","y","z"]),("b",["p","r"])])>>>deff(x):returnx...>>>rdd.flatMapValues(f).collect()[('a', 'x'), ('a', 'y'), ('a', 'z'), ('b', 'p'), ('b', 'r')]