title: How to turn array<int> to int in pyspark?
body: <p>Let's say I have the following dataframe:</p>
  
  <p><code>my_x = [([1,100]), ([2]), ([3,2])]
  my_df = spark.createDataFrame(my_x, ArrayType(IntegerType()))</code></p>
  
  <p>Now, I want to extract the first element (int) from each array-row. So the final dataframe would have 1,2,3 (one per row). Is there a way of doing this without using a UDF? I tried doing something like</p>
  
  <p><code>my_df.withColumn("casted", my_df.value.getItem(IntegerType()))</code></p>
  
  <p>to no avail. </p>
  
  <p>Thanks!</p>