pyspark.RDD.foreach

RDD.foreach(f: Callable[[T], None]) → None[source]

Applies a function to all elements of this RDD.

New in version 0.7.0.

Parameters
ffunction

a function applyed to each element

Examples

>>> def f(x): print(x)
>>> sc.parallelize([1, 2, 3, 4, 5]).foreach(f)