if __name__ == '__main__':
    sc = SparkContext(appName='distinctTuples', conf=SparkConf().set(
        'spark.driver.host', 'localhost'))
dataset = [('1', 'y'), ('1', 'y'), ('1', 'y'), ('1', 'n'), ('1',
    'n'), ('2', 'y'), ('2', 'n'), ('2', 'n')]
allTuplesRdd = sc.parallelize(dataset, 4)
distinctTuplesRdd = allTuplesRdd.distinct()
distinctTuples = distinctTuplesRdd.collect()
How to remove duplicate values from a RDD[PYSPARK]