title: How to use map() to convert (key,values) pair to values only in Pyspark
body: <p>I have this code in PySpark to .</p>
  
  <pre><code>wordsList = ['cat', 'elephant', 'rat', 'rat', 'cat']
  wordsRDD = sc.parallelize(wordsList, 4)
  
  
  wordCounts = wordPairs.reduceByKey(lambda x,y:x+y)
  print wordCounts.collect()
  
  #PRINTS--&gt;  [('rat', 2), ('elephant', 1), ('cat', 2)]
  
  from operator import add
  totalCount = (wordCounts
                .map(&lt;&lt; FILL IN &gt;&gt;)
                .reduce(&lt;&lt; FILL IN &gt;&gt;))
  
  #SHOULD PRINT 5
  
  #(wordCounts.values().sum()) // does the trick but I want to this with map() and reduce()
  
  
  I need to use a reduce() action to sum the counts in wordCounts and then divide by the number of unique words.
  </code></pre>
  
  <p>*    But first I need to <strong>map() the pair RDD wordCounts, which consists of (key, value) pairs, to an RDD of values</strong>.</p>
  
  <p>This is where I am stuck. I tried something like this below, but none of them work:</p>
  
  <pre><code>.map(lambda x:x.values())
  .reduce(lambda x:sum(x)))
  
  AND,
  
  .map(lambda d:d[k] for k in d)
  .reduce(lambda x:sum(x)))
  </code></pre>
  
  <p>Any help in this would be highly appreciated!</p>