pyspark.sql.DataFrame.foreachPartition¶
-
DataFrame.
foreachPartition
(f: Callable[[Iterator[pyspark.sql.types.Row]], None]) → None¶ Applies the
f
function to each partition of thisDataFrame
.This a shorthand for
df.rdd.foreachPartition()
.Examples
>>> def f(people): ... for person in people: ... print(person.name) >>> df.foreachPartition(f)