title: How can I resolve the "need struct type but got struct"
body: <p><a href="https://i.stack.imgur.com/2a8G9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2a8G9.png" alt="enter image description here"></a></p>
  
  <p>As you can see on my picture, I have a column named probability and I want to create a new column from the <strong>probability</strong> column. I want to extract values from the probability column which is an array. But while trying to do so, I receive an error:</p>
  
  <p><code>"Can't extract value from probability#52427: need struct type but got struct&lt;type:tinyint,size:int,indices:array&lt;int&gt;,values:array&lt;double&gt;&gt;"</code></p>
  
  <p>Here is my extraction code:</p>
  
  <p><code>preds_test = preds.withColumn("newCol", col("probability").getItem(3))</code></p>
  
  <p>Can someone please tell me what I did wrong?</p>