python/pyspark/rdd.py
def groupByKey(self, numPartitions=None):
        """
        Group the values for each key in the RDD into a single sequence.
        Hash-partitions the resulting RDD with into numPartitions partitions.

        >>> x = sc.parallelize([("a", 1), ("b", 1), ("a", 1)])
        >>> map((lambda (x,y): (x, list(y))), sorted(x.groupByKey().collect()))
        [('a', [1, 1]), ('b', [1])]
        """

        def createCombiner(x):
            return [x]

        def mergeValue(xs, x):
            xs.append(x)
            return xs

        def mergeCombiners(a, b):
            return a + b

        return self.combineByKey(createCombiner, mergeValue, mergeCombiners,
                numPartitions).mapValues(lambda x: ResultIterable(x))

        Group the values for each key in the RDD into a single sequence.
        Hash-partitions the resulting RDD with into numPartitions partitions.

        >>> x = sc.parallelize([("a", 1), ("b", 1), ("a", 1)])
        >>> map((lambda (x,y): (x, list(y))), sorted(x.groupByKey().collect()))
        [('a', [1, 1]), ('b', [1])]
        
Group the values for each key in the RDD into a single sequence.
Hash-partitions the resulting RDD with into numPartitions partitions.


Group the values for each key in the RDD into a single sequence . Hash - partitions the resulting RDD with into numPartitions partitions .
def groupByKey(self, numPartitions=None):
        def createCombiner(x):
            return [x]
        def mergeValue(xs, x):
            xs.append(x)
            return xs
        def mergeCombiners(a, b):
            return a + b
        return self.combineByKey(createCombiner, mergeValue, mergeCombiners,
                numPartitions).mapValues(lambda x: ResultIterable(x))
def groupByKey ( self , numPartitions = None ) : def createCombiner ( x ) : return [ x ] def mergeValue ( xs , x ) : xs . append ( x ) return xs def mergeCombiners ( a , b ) : return a + b return self . combineByKey ( createCombiner , mergeValue , mergeCombiners , numPartitions ) . mapValues ( lambda x : ResultIterable ( x ) )
Group the values for each key in the RDD into a single sequence.
Group the values for each key in the RDD into a single sequence .
"""
        Group the values for each key in the RDD into a single sequence.
        Hash-partitions the resulting RDD with into numPartitions partitions.

        >>> x = sc.parallelize([("a", 1), ("b", 1), ("a", 1)])
        >>> map((lambda (x,y): (x, list(y))), sorted(x.groupByKey().collect()))
        [('a', [1, 1]), ('b', [1])]
        """
self
numPartitions