pyspark.sql.DataFrame.foreach

DataFrame.foreach(f: Callable[[pyspark.sql.types.Row], None]) → None

Applies the f function to all Row of this DataFrame.

This is a shorthand for df.rdd.foreach().

Examples

>>> def f(person):
...     print(person.name)
>>> df.foreach(f)