pyspark.RDD.foreachPartition

RDD.foreachPartition(f)[source]

Applies a function to each partition of this RDD.

Examples

>>> def f(iterator):
...     for x in iterator:
...          print(x)
>>> sc.parallelize([1, 2, 3, 4, 5]).foreachPartition(f)