pyspark.RDD.subtract¶
-
RDD.
subtract
(other: pyspark.rdd.RDD[T], numPartitions: Optional[int] = None) → pyspark.rdd.RDD[T]¶ 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)]