title: get first N elements from dataframe ArrayType column in pyspark
body: <p>I have a spark dataframe with rows as - </p>
  
  <pre><code>1   |   [a, b, c]
  2   |   [d, e, f]
  3   |   [g, h, i]
  </code></pre>
  
  <p>Now I want to keep only the first 2 elements from the array column.</p>
  
  <pre><code>1   |   [a, b]
  2   |   [d, e]
  3   |   [g, h]
  </code></pre>
  
  <p>How can that be achieved?    </p>
  
  <p>Note - Remember that I am not extracting a single array element here, but a part of the array which may contain multiple elements.</p>