pyspark.RDD.keys

RDD.keys() → pyspark.rdd.RDD[K][source]

Return an RDD with the keys of each tuple.

New in version 0.7.0.

Returns
RDD

a RDD only containing the keys

See also

RDD.values()

Examples

>>> rdd = sc.parallelize([(1, 2), (3, 4)]).keys()
>>> rdd.collect()
[1, 3]