Extracting a sub array from PySpark DataFrame column : <p>I wish to remove the last element of the array from this DataFrame. We have this <a href="https://stackoverflow.com/questions/40134975/selecting-a-range-of-elements-in-an-array-spark-sql/40136386">link</a> demonstrating the same thing, but with <code>UDFs</code> and that I wish to avoid. Is there is simple way to do this - something like <code>list[:2]</code>?</p>

<pre><code>data = [(['cat','dog','sheep'],),(['bus','truck','car'],),(['ice','pizza','pasta'],)]
df = sqlContext.createDataFrame(data,['data'])
df.show()
+-------------------+
|               data|
+-------------------+
|  [cat, dog, sheep]|
|  [bus, truck, car]|
|[ice, pizza, pasta]|
+-------------------+
</code></pre>

<p>Expected DataFrame:</p>

<pre><code>+--------------+
|          data|
+--------------+
|    [cat, dog]|
|  [bus, truck]|
|  [ice, pizza]|
+--------------+
</code></pre>
