foreachPartition
このDataFrameの各パーティションにf関数を適用します。
構文
foreachPartition(f: Callable[[Iterator[Row]], None])
パラメーター
パラメーター | Type | 説明 |
|---|---|---|
| function | 処理する各パーティションを受け取る 1 つの問題を受け入れる関数。 |
例
Python
df = spark.createDataFrame(
[(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"])
def func(itr):
for person in itr:
print(person.name)
df.foreachPartition(func)