title: How to access element of a VectorUDT column in a Spark DataFrame?
body: <p>I have a dataframe <code>df</code> with a <code>VectorUDT</code> column named <code>features</code>. How do I get an element of the column, say first element? </p>
  
  <p>I've tried doing the following</p>
  
  <pre class="lang-py prettyprint-override"><code>from pyspark.sql.functions import udf
  first_elem_udf = udf(lambda row: row.values[0])
  df.select(first_elem_udf(df.features)).show()
  </code></pre>
  
  <p>but I get a <code>net.razorvine.pickle.PickleException: expected zero arguments for construction of ClassDict(for numpy.dtype)</code> error. Same error if I do <code>first_elem_udf = first_elem_udf(lambda row: row.toArray()[0])</code> instead.</p>
  
  <p>I also tried <code>explode()</code> but I get an error because it requires an array or map type.</p>
  
  <p>This should be a common operation, I think.</p>