pyspark.SparkContext.parallelize

SparkContext.parallelize(c, numSlices=None)[source]

Distribute a local Python collection to form an RDD. Using range is recommended if the input represents a range for performance.

Examples

>>> sc.parallelize([0, 2, 3, 4, 6], 5).glom().collect()
[[0], [2], [3], [4], [6]]
>>> sc.parallelize(range(0, 6, 2), 5).glom().collect()
[[], [0], [], [2], [4]]