PySpark Cookbook
上QQ阅读APP看书,第一时间看更新

.count() action

The count() action returns the number of elements in the RDD. See the following code:

(
flights
.zipWithIndex()
.filter(lambda (row, idx): idx > 0)
.map(lambda (row, idx): row)
.count()
)

This will produce the following result:

# Output
1391578