PySpark groupByKey returning pyspark.resultiterable.ResultIterable

后端 未结 6 1296
不思量自难忘°
不思量自难忘° 2021-01-30 16:24

I am trying to figure out why my groupByKey is returning the following:

[(0, ), (1, 

        
6条回答
  •  情话喂你
    2021-01-30 16:52

    What you're getting back is an object which allows you to iterate over the results. You can turn the results of groupByKey into a list by calling list() on the values, e.g.

    example = sc.parallelize([(0, u'D'), (0, u'D'), (1, u'E'), (2, u'F')])
    
    example.groupByKey().collect()
    # Gives [(0, 

提交回复
热议问题