title: Spark mapPartitionsWithIndex : Identify a partition
body: <p>Identify a partition :</p>
  
  <pre><code>mapPartitionsWithIndex(index, iter)
  </code></pre>
  
  <p>The method results into driving a function onto each partition. I understand that we can track the partition using "index" parameter.</p>
  
  <p>Numerous examples have used this method to remove the header in a data set using "index = 0" condition. But how do we make sure that the first partition which is read (translating, "index" parameter to be equal to 0) is indeed the header. Isint it random or based upon the partitioner, if used.</p>