pyspark.RDD.subtract

RDD.subtract(other, numPartitions=None)[source]

Return each value in self that is not contained in other.

Examples

>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 3)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtract(y).collect())
[('a', 1), ('b', 4), ('b', 5)]