title: How do you utilize partition information in a map on each row?
body: <p>I am trying to code an ML algorithm from scratch in Spark and I am having an issue in setting up a histogram of each feature across each partition.</p>
  
  <p>The goal is have some final variable <code>N</code>, and get the <code>max</code> and <code>min</code> of each column <em>within each partition</em>. Then I want to map the rows to bucket them in the <code>N</code> bins with the bin length as <code>(max - min)/N</code>. I have tried <code>mapWithIndex</code> to get the <code>max</code> but then I am not sure how to tie this back to a <code>map</code> function and make sure the correct <code>max</code> is connected with the correct partition.</p>