title: Group rdd based on a value in pyspark
body: <p>I have created an rdd and print the results with:</p>
  
  <pre><code>finalRDD = replacetimestampRDD.map(lambda x: (x[1], x[0:]))
  print("Partitions structure: {}".format(finalRDD.glom().collect()))
  </code></pre>
  
  <p>Output (an example):</p>
  
  <pre><code>Partitions structure: [[('a', ['2020-05-22 15:17:10', 'John', '9535175']), 
                          ('b', ['2020-05-22 15:17:10', 'Nick', '7383554',]),
                          ('c', ['2020-05-22 15:17:10', 'George', '8915433']),
                          ('a', ['2020-05-22 15:17:10', 'Paul', '9615224'])
                        ]]
  </code></pre>
  
  <p>I try to group the results by key (by key I mean 'a','b','c'). Desired output:</p>
  
  <pre><code>Partitions structure: [[('a', [['2020-05-22 15:17:10', 'John', '9535175'],['2020-05-22 15:17:10', 'Paul', '9615224']]), 
                          ('b', ['2020-05-22 15:17:10', 'Nick', '7383554',]),
                          ('c', ['2020-05-22 15:17:10', 'George', '8915433'])
                            ]]
  </code></pre>
  
  <p>I try with <code>results = finalRDD.groupByKey().collect()</code> but it doesn't seem to work?</p>
  
  <p>Can anyone help me with this? </p>