title: How to repartition evenly in Spark?
body: <p>To test how <code>.repartition()</code> works, I ran the following code:</p>
  
  <pre><code>rdd = sc.parallelize(range(100))
  rdd.getNumPartitions()
  </code></pre>
  
  <p><code>rdd.getNumPartitions()</code> resulted in <code>4</code>. Then I ran:</p>
  
  <pre><code>rdd = rdd.repartition(10)
  rdd.getNumPartitions()
  </code></pre>
  
  <p><code>rdd.getNumPartitions()</code> this time resulted in <code>10</code>, so there were now 10 partitions.</p>
  
  <p>However, I checked the partitions by:</p>
  
  <pre><code>rdd.glom().collect()
  </code></pre>
  
  <p>The result gave 4 non-empty lists and 6 empty lists. Why haven't any elements been distributed to the other 6 lists?</p>